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.

Chapter 15 ✦ The NN4 Layer Object (Chapter 31)<br />

<br />

layer.left:<br />

<br />

<br />

<br />

layer.top:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

ARTICLE I<br />

<br />

Congress shall make no law respecting an establishment of religion, or<br />

prohibiting the free exercise thereof; or abridging the freedom of speech, or of<br />

the press; or the right of the people peaceably to assemble, and to petition the<br />

government for a redress of grievances.<br />

<br />

<br />

<br />

<br />

<br />

src<br />

Compatibility ✓<br />

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

Example<br />

Setting the layerObject.src property of a layer that is a member of a layer<br />

family (that is, a family with at least one parent and one child) can be tricky business<br />

if you’re not careful. Listing 31-7 presents a workspace for you to see how<br />

changing the src property of outer and inner layers affects the scenery.<br />

When you first load the document, one outer layer contains one inner layer (each<br />

with a different background color). Control buttons on the page enable you to set<br />

the layerObject.src property of each layer independently. Changes to the inner<br />

layer content affect only that layer. Long content forces the inner layer to expand its<br />

depth, but the inner layer’s view is automatically clipped by its parent layer.<br />

Changing the outer layer content, however, removes the inner layer completely.<br />

Code in the following listing shows one way to examine for the presence of a<br />

particular layer before attempting to load new content in it. If the inner layer doesn’t<br />

exist, the script creates a new layer on the fly to replace the original inner layer.<br />

455<br />

document.layerObject.src

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

Saved successfully!

Ooh no, something went wrong!