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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

available width & height 1

Status
Not open for further replies.

jtaal

Technical User
Jan 17, 2004
23
NL
How do i find out the available width and height of a browser window. I checked out some docs and it said window.innerHeight and window.innerWidth. But:
when i do
Code:
alert (window.innerHeight);
using IE 6.0 it says 'undefined' while using Mozilla 1.6 it gives me a reasonable 698...
i also checked out document.body.clientHeight, but when i use a different doctype (loose or strict) it gives larger values, because my doc is larger than just one page. So i couldnt us that...

Any help?
 
basically you need code for each type of browser (NN IE Mozilla etc) not all respond to js the same way or use the same js attributes...

google test for browser and screen width and height to get some code samples you can adapt (or steal)

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
this is what i finally found :)
Code:
var x,y;
if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
	y = document.body.clientHeight;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top