15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

138<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

The last statement in the example shows how to use the array syntax (brackets)<br />

to refer to a specific frame. All array indexes start with 0 for the first entry. Because<br />

the document asks for the name of the first frame (parent.frames[0]), the<br />

response is JustAKid1 for both frames.<br />

innerHeight<br />

innerWidth<br />

outerHeight<br />

outerWidth<br />

windowObject.innerHeight<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓<br />

Example<br />

In Listing 16-9, a number of buttons let you see the results of setting the<br />

innerHeight, innerWidth, outerHeight, and outerWidth properties.<br />

Listing 16-9: Setting Window Height and Width<br />

<br />

<br />

Window Sizer<br />

<br />

// store original outer dimensions as page loads<br />

var originalWidth = window.outerWidth<br />

var originalHeight = window.outerHeight<br />

// generic function to set inner dimensions<br />

function setInner(width, height) {<br />

window.innerWidth = width<br />

window.innerHeight = height<br />

}<br />

// generic function to set outer dimensions<br />

function setOuter(width, height) {<br />

window.outerWidth = width<br />

window.outerHeight = height<br />

}<br />

// restore window to original dimensions<br />

function restore() {<br />

window.outerWidth = originalWidth<br />

window.outerHeight = originalHeight<br />

}<br />

<br />

<br />

<br />

<br />

Setting Inner Sizes

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

Saved successfully!

Ooh no, something went wrong!