DelphiFAQ Home Search:

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

 

comments3 comments. Current rating: 5 stars (1 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-10-22, 23:47:09
m from Philippines  
rating
It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this.
[url= http://www.megaabst..seo[/url]
http://www.megaabst..berseo.com
2012-11-12, 02:45:52
anonymous from United Kingdom  
2012-11-18, 21:32:52
ngbnn  

 

 

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: