15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

460<br />

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

3-2-1, 1-3-2, 2-2-2, and so on. Each time you enter one new value, check the actual<br />

layers to see if their stacking order changed and how that affected the other properties<br />

of all layers. Listing 31-20 in the <strong>JavaScript</strong> <strong>Bible</strong> shows how to achieve the<br />

same action with IE5+ and NN6+ syntax.<br />

Listing 31-9: Relationships Among zIndex, above, and below<br />

<br />

<br />

Layer zIndex<br />

<br />

function setZ(field) {<br />

switch (field.name) {<br />

case “top” :<br />

document.top.zIndex = parseInt(field.value)<br />

break<br />

case “mid” :<br />

document.middle.zIndex = parseInt(field.value)<br />

break<br />

case “bot” :<br />

document.bottom.zIndex = parseInt(field.value)<br />

}<br />

showValues()<br />

}<br />

function showValues() {<br />

document.layers[0].document.forms[0].bot.value = document.bottom.zIndex<br />

document.layers[1].document.forms[0].mid.value = document.middle.zIndex<br />

document.layers[2].document.forms[0].top.value = document.top.zIndex<br />

document.layers[0].document.forms[0].above.value = (document.bottom.above) ?<br />

document.bottom.above.name : “(none)”<br />

document.layers[1].document.forms[0].above.value = (document.middle.above) ?<br />

document.middle.above.name : “(none)”<br />

document.layers[2].document.forms[0].above.value = (document.top.above) ?<br />

document.top.above.name : “(none)”<br />

document.layers[0].document.forms[0].below.value = (document.bottom.below) ?<br />

document.bottom.below.name : “(none)”<br />

document.layers[1].document.forms[0].below.value = (document.middle.below) ?<br />

document.middle.below.name : “(none)”<br />

document.layers[2].document.forms[0].below.value = (document.top.below) ?<br />

document.top.below.name : “(none)”<br />

}<br />

<br />

<br />

<br />

Setting the layer.zIndex Property of Sibling Layers<br />

<br />

Enter new zIndex values to see the effect on three layers.<br />

<br />

document.layerObject.zIndex

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

Saved successfully!

Ooh no, something went wrong!