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.

304<br />

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

TextRange.findText()<br />

Now, insert the copy at the very end of the body:<br />

a.text = b.text<br />

If you scroll to the bottom of the page, you’ll see a copy of the text.<br />

execCommand(“commandName”[, UIFlag[,<br />

value]])<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 see how to copy a text<br />

range’s text into the client computer’s Clipboard. Begin by setting the text range to<br />

the myP element:<br />

a = document.body.createTextRange()<br />

a.moveToElementText(myP)<br />

Now use execCommand() to copy the range into the Clipboard:<br />

a.execCommand(“Copy”)<br />

To prove that the text is in the Clipboard, click the bottom text field and choose<br />

Paste from the Edit menu (or press Ctrl+V).<br />

expand(“unit”)<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

You can find examples of the expand() method in Listing 15-14.<br />

findText(“searchString”[, searchScope,<br />

flags])<br />

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

Compatibility ✓ ✓ ✓

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

Saved successfully!

Ooh no, something went wrong!