Forum Moderators: open

Message Too Old, No Replies

why doesn't this work?

         

achisholm

10:47 am on Apr 8, 2005 (gmt 0)

10+ Year Member



I am trying to get this to work in Internet Explorer 5 and all i get is a blank page

<html>
<script>
window.onresize{
var x = document.documentElement.offsetWidth
var y = document.documentElement.offsetHeight
document.write( x+ ", "+ y);
}
</script>
</html>

JAB Creations

9:40 pm on Apr 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Trying to get the width and height of the available rendering area?

rocknbil

5:25 pm on Apr 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do this instead:

window.onresize{
var x = document.documentElement.offsetWidth
var y = document.documentElement.offsetHeight
alert( x+ ", "+ y);
}

Or

window.onresize{
var x = document.documentElement.offsetWidth
var y = document.documentElement.offsetHeight
document.sizeme.x_val.value=x;
document.sizeme.y_val.value=y;
}

<form name="sizeme">
X: <input type="text" name="x_val" value=""><br>
Y: <input type="text" name="y_val" value="">
</form>

When you compare the results with your original, you'll see the problem. :-)

Bernard Marx

5:31 pm on Apr 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you mean:

[pre]window.onresize = function()
{
// blah
}[/pre]

Rambo Tribble

1:59 am on Apr 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since the documentElement is a reference to the html element, I expect it will be necessary to give it (the html element) a CSS height value of 100% in order to get values returned on IE.

rocknbil

5:47 pm on Apr 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, Thx. Bernard. :-D