I'm trying to figure out why this code does not work until I refresh the screen!
I copied the code below to an htm file on my disk. When I double clicked the file the first line is 1920 x 1200. The second line is 0 x 0. When I then hit F5 to refresh the screen the second line changes to 562 x 435 which is the proper size of my small browser window.
Why does it come up 0 x 0 when I load the page from disk?
This is also true when IE is already open and it has to create a new tab for the file from disk.
I copied the code below to an htm file on my disk. When I double clicked the file the first line is 1920 x 1200. The second line is 0 x 0. When I then hit F5 to refresh the screen the second line changes to 562 x 435 which is the proper size of my small browser window.
Why does it come up 0 x 0 when I load the page from disk?
This is also true when IE is already open and it has to create a new tab for the file from disk.
Code:
<!-- saved from url=(0014)about:internet -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Display window size</TITLE>
</HEAD>
<BODY>
<SCRIPT language="JavaScript">
<!--
height = screen.height;
width = screen.width;
document.write( width + " x " + height + "<br>");
if (document.layers) {
width = window.innerWidth;
depth = window.innerDepth;
}
// Explorer 6 Strict Mode
else if (document.documentElement && document.documentElement.clientHeight) {
width = document.documentElement.clientWidth;
depth = document.documentElement.clientHeight;
}
else if (document.all) {
width = document.body.clientWidth;
depth = document.body.clientHeight;
}
document.write( width + " x " + depth + "<br>");
//-->
</SCRIPT>
</BODY>
</HTML>
Last edited: