spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / javascript / domscripting / 2 To page 1To page 2current pageTo page 4
[previous][next]
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Scripting for 5th Generation Browsers and Beyond

Capturing Browser Dimensions

Let's get back to positioning our layers by browser dimensions. You will note that instead of assigning a numeric value to the left and top attributes of the new layer object, page_width and page_height are used. These are variables created and set at the onLoad event handler:

onLoad="
if(is.ns6) {
page_width=innerWidth;
page_height=innerHeight;
layerSetup();
} else if(is.ie5 || is.ie55||is.ie6) {
page_width=document.body.clientWidth;
page_height=document.body.clientHeight;
layerSetup();
}"

Once again we need to create a little cross browser and backward compatible DOM switch. Netscape 4 and Netscape 6 use innerWidth and innerHeight to detect a user's screen resolution. Therefore, we create a browser detection condition.

if(is.ns6) {

if this condition holds true then the variables page_width and page_height are assigned the correct DOM method for Netscape 6 and the layerSetup() script is triggered.

page_width=innerWidth;
page_height=innerHeight;
layerSetup();

If the condition is not true then attention is focused on the Internet Explorer part of the script and the DOM for those browsers is utilized.

} else if(is.ie5 || is.ie55 || is.ie6) {
page_width=document.body.clientWidth;
page_height=document.body.clientHeight;
layerSetup();
}"

Contents:

home / programming / javascript / domscripting / 2 To page 1To page 2current pageTo page 4
[previous][next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Created: August 22, 2001
Revised: August 22, 2001


URL: http://webreference.com/programming/javascript/domscripting/2/3.html