DelphiFAQ Home Search:
General :: Programming :: JavaScript
Code snippets to add functionality to your HTML pages, preferably cross-browser.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

How do I read or set the browser's window size?

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) {
   // Netscape code
   oH = window.outerHeight; 
   oW = window.outerWidth; 
 
   alert("Height: " + oH + "px Width: " + oW + "px"); 
 
   // resize to 500 x 400
   window.outerHeight = 500; 
   window.outerWidth = 400; 
 }
 else {
   // Internet Explorer
   // clientWidth/Height is inner window size 
   //                    (subtract the pixels used by scroll bar, menu etc)
 
   iW = document.body.clientWidth; 
   iH = document.body.clientHeight; 
   alert("Inner Width: " + iW + "px Inner Height:" + iH); 
 
   self.resizeTo(500,400);
 }
 </script> 
 

Generated 20:02:09 on Oct 22, 2018