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.

Once we know what kind of layer-aware browser we are dealing with, we might define a set of<br />

common functions to manipulate the layers. We define the following layer functions to handle<br />

common tasks:<br />

function hide(layerName) { }<br />

function show(layerName) { }<br />

function setX(layerName, x) { }<br />

function setY(layerName, y) { }<br />

function setZ(layerName, zIndex) { }<br />

function setHeight(layerName, height) { }<br />

function setWidth(layerName, width) { }<br />

function setClip(layerName, top, right, bottom, left) { }<br />

function setContents( ) { }<br />

<strong>The</strong>se are just stubs that we will fill out shortly, but first we will need one special routine in all of<br />

them to retrieve positioned elements by name, since each approach does this slightly<br />

differently.<br />

function getElement(layerName, parentLayer)<br />

{<br />

if(layerobject)<br />

{<br />

parentLayer = (parentLayer) ? parentLayer : self;<br />

layerCollection = parentLayer.document.layers;<br />

if (layerCollection[layerName])<br />

return layerCollection[layerName];<br />

/* look through nested layers */<br />

for (i=0; i

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

Saved successfully!

Ooh no, something went wrong!