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


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.

 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); 

Generated 8:01:29 on Aug 11, 2020