DelphiFAQ Home Search:

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


comments7 comments. Current rating: 3 stars (4 votes). Leave comments and/ or 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.

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


Content-type: text/html


2012-11-12, 02:45:52
anonymous from United Kingdom  
2012-11-18, 21:32:52
2017-11-27, 19:55:29
anonymous from Indonesia  
2020-07-03, 08:36:51
2020-07-07, 11:37:13
Ana from Uzbekistan  
what is better than albuterol
2020-07-26, 19:19:22
tylenol tablets 500 mg
2020-08-18, 06:22:04
albuterol sulfate inhalation solution cost



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: