DelphiFAQ Home Search:

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

 

comments9 comments. Current rating: 2 stars (6 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.

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

Comments:

2012-11-12, 02:45:52
anonymous from United Kingdom  
2012-11-18, 21:32:52
ngbnn  
2017-11-27, 19:55:29
anonymous from Indonesia  
2020-06-28, 17:11:21
Nestor  
rating
can you buy hydroxychloroquine over the counter
2020-07-03, 08:36:51
Jestine  
rating
clomiphene
2020-07-07, 11:37:13
Ana from Uzbekistan  
rating
what is better than albuterol
2020-07-23, 07:57:06
Aileen from Germany  
rating
viagra without doctor prescription
2020-07-26, 19:19:22
Gregory  
rating
tylenol tablets 500 mg
2020-08-12, 20:00:48
Kristofer from Den Haag, Netherlands  
rating
can you buy hydroxychloroquine over the counter

 

 

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: