11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<br />

A rendering of the example is shown next.<br />

One thing that is rather troublesome with this detection is that the availHeight and availWidth<br />

properties indicate the height and width of the screen minus any operating system chrome<br />

rather than, as one might expect, the actual size of the available browser window. In order to<br />

detect actual window size, you have to use properties of the Window object in the case of<br />

Netscape. In the case of Internet Explorer, you need to look into the Document object and<br />

examine the body itself. However, in the case of the DOM, you might want to look at the size of<br />

the root element, namely, the tag, and not the if you are trying to get the<br />

dimensions of the window. Of course, which tag to look at depends on what rendering mode<br />

your browser is in, either loose or strict, which is generally determined by the doctype<br />

statement in the document. This example shows how you might check all this. Invariably,<br />

something might change given the lack of agreement among browser vendors on how to<br />

implement certain CSS, XHTML, and <strong>JavaScript</strong> ideas, but the example should still<br />

demonstrate the concept:<br />

<br />

<br />

<br />

Available Region Checker<br />

<br />

<br />

<br />

Resize your browser window

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!