Programming C# C++ (7) Delphi (617) Java (8) JavaScript (31) Document (8) Events (8) ExtJS (9) Strings (3) perl (9) php (4) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us 
New related comments Number of comments in the last 48 hoursHow to prompt the user with an inputbox in Javascript 2 new comments
|
How do I read or set the browser's window size?
This article has not been rated yet. After reading, feel free to leave comments and rate it.
As often, Netscape and Internet Explorer use different properties to store the window size. After determining the browser type, the code uses either Netscape's innerHeight and innerWidth properties or IE's resizeto() function.
Other usefule functions available in IE are
self.resizeBy(x, y)
self.moveTo(x, y)
self.moveBy(x, y)
Note that in order to read the size related properties in Internet Explorer, this javascript has to be placed behind the tag.
 | |  | | <script>
if (window.outerHeight) {
oH = window.outerHeight;
oW = window.outerWidth;
alert("Height: " + oH + "px Width: " + oW + "px");
window.outerHeight = 500;
window.outerWidth = 400;
}
else {
iW = document.body.clientWidth;
iH = document.body.clientHeight;
alert("Inner Width: " + iW + "px Inner Height:" + iH);
self.resizeTo(500,400);
}
</script>
| |  | |  |
Comments:
|