ID:105059
 
Not a bug
BYOND Version:479
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Opera 10.63
Applies to:Dream Seeker
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
Well, when running JavaScript through the embedded browser element, the window object is completely useless. Every variable attached to it is completely empty.

Code Snippet (if applicable) to Reproduce Problem:
client
New()
src << output("<html><body onresize=\"location.replace('byond://?resize=true&window='+window.name+'&newx='+window.outerHeight+'&newy='+window.screenX+'');\" ></body></html>","browser")
..()

Topic(href,href_list[]) if(href_list["resize"]) world << "[href_list["var1"]] | [href_list["var2"]] | [href_list["var3"]]"

Note: The auto-filters caught "onresize" and replaced it with "disabledresize".

Expected Results:
To output the name of the window, the height of the window, and the position of the window on the horizontal axis.

Actual Results:
It outputs " | | ".

Workarounds:
Ha! This was supposed to be a workaround for something else, a last resort, if you will.

Notes:
These were supposed to be used for a window tracker. Instead of having a loop running a winget() for every client to keep track of positions and whatnot, I could use a couple clever tricks with the window's variables to do it on the client's end. Without access to these, the features that I'm working on are almost impossible to implement and impossible to implement gently.
I suspect this is because IE doesn't support the outerHeight or screenX properties and that window.name is an empty string. See http://www.quirksmode.org/dom/w3c_cssom.html

var properties = "";
for(var p in window)
{
properties += p + "\n";
}
alert(properties);


This will tell you what properties are available. It looks like you might be able to use document.body.offsetWidth and document.body.offsetHeight instead.
Well, I cannot believe that I overlooked that little tidbit. Very perceptive of me. I guess I'll have to wait until Microsoft finishes pulling their heads out with IE9.

P.S. Why couldn't we have a real browser again?

P.P.S. It'd still be nice if window.name wasn't empty.
If they fix everything in IE9 you still can't count on all BYOND users having it. It would be nice if BYOND came packaged with its own browser for consistency reasons. Most of web development involves dealing with browser inconsistencies, but it'd be nice if DM developers didn't have to deal with that too.

I did a quick test and document.body.offsetWidth/Height give the same values as winget reports for the window's size.
True, and I'd hate to have to block users from features simply because they don't have the latest version of a pile of crap.

And thanks for the heads up. I guess that I'll have to work around the workaround.