Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determining the window width

Status
Not open for further replies.

gollyg

Technical User
Oct 24, 2000
131
AU
Is there any cross-browser compatable method of determining the inner width of the browser window. I've just been looking at the javascript object table and I'm surprised to see that this property does not seem to be supported (other than by Netscape 4+). I know you can get the screen width but that doesn't tell you much about the size of the browser.

I guess I'm hoping someone has come up with a trick. I thought you might be able to set a table to 100% and then retrieve its width, but no cigar, tables aren't even recognised (according to my object list).

Any help much appreciated.

j
 
see thread216-26851 and thread216-25440 in the jscript forum


 
Percentage is not recommendable. The layout cannot be stabilized.
Based on 800 x 600 or 1024 x 768 use tables with width=750 pixels.
-----G.Hoffmann
 
gollyg,

var sout = new String("Width: ");
// use whatever mechanism you need to determine
// IE vs NS
if ( document.all){
sout += document.body.offsetWidth;
}else{
sout =+ window.innerWidth;
}
window.status = sout;

Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top