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.

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

Notice that although you can no longer adjust the font size from the lower text<br />

box, the most recent value assigned to it still sticks to the element. To prove it,<br />

enter the following statement in the topmost text box to see the current value:<br />

myP.style.fontSize<br />

removeNode(removeChildrenFlag)<br />

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

Compatibility ✓ ✓<br />

Example<br />

Examine Listing 15-21 for the appendChild() method to understand the difference<br />

between removeChild() and removeNode(). In the restore() function, you<br />

can replace this statement<br />

mainObj.removeChild(oneChild)<br />

in IE5+ with<br />

oneChild.removeNode(true)<br />

The difference is subtle, but it is important to understand. See Listing 15-31 later<br />

in this chapter for another example of the removeNode() method.<br />

replaceAdjacentText(“location”, “text”)<br />

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

Compatibility ✓ ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to experiment with the<br />

replaceAdjacentText() method. Enter each of the following statements into the<br />

top text box and watch the results in the myP element (and its nested myEM element)<br />

below the solid rule:<br />

document.all.myEM.replaceAdjacentText(“afterBegin”, “twenty”)<br />

Notice that the myEM element’s new text picks up the behavior of the element. In<br />

the meantime, the replaced text (all) is returned by the method and displayed in<br />

the Results box.<br />

document.all.myEM.replaceAdjacentText(“beforeBegin”, “We need “)<br />

elementObject.replaceAdjacentText()

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

Saved successfully!

Ooh no, something went wrong!