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.

Chapter 4 ✦ The Document and Body Objects (Chapter 18)<br />

<br />

Cell A1<br />

Cell B1<br />

<br />

<br />

Cell A2<br />

Cell B2<br />

<br />

<br />

Section 1<br />

Lorem ipsum dolor sit amet, consectetaur adipisicing elit,<br />

sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br />

Ut enim adminim veniam, quis nostrud exercitation ullamco laboris<br />

nisi ut aliquip ex ea commodo consequat.<br />

Section 2<br />

Duis aute irure dolor in reprehenderit involuptate velit esse<br />

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat<br />

cupidatat non proident, sunt in culpa qui officia deseruntmollit<br />

anim id est laborum.<br />

<br />

Here is a positioned element.<br />

<br />

<br />

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

param])<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

You can find many examples of the execCommand() method for the TextRange<br />

object in Chapter 19 of the <strong>JavaScript</strong> <strong>Bible</strong>. But you can try out the documentspecific<br />

commands in The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) if you like.<br />

Try each of the following statements in the top text box and click the Evaluate button:<br />

document.execCommand(“Refresh”)<br />

document.execCommand(“SelectAll”)<br />

document.execCommand(“Unselect”)<br />

All methods return true in the Results box.<br />

Because any way you can evaluate a statement in The Evaluator forces a body<br />

selection to become deselected before the evaluation takes place, you can’t experiment<br />

this way with the selection-oriented commands.<br />

249<br />

document.execCommand()

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

Saved successfully!

Ooh no, something went wrong!