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.

292<br />

selection.clear()<br />

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

Listing 19-7: Using the document.selection Object<br />

<br />

<br />

selection Object<br />

<br />

function processSelection() {<br />

if (document.choices.process[0].checked) {<br />

status = “Selection is type: “ + document.selection.type<br />

setTimeout(“emptySelection()”, 2000)<br />

} else if (document.choices.process[1].checked) {<br />

var rng = document.selection.createRange()<br />

document.selection.clear()<br />

}<br />

}<br />

function emptySelection() {<br />

document.selection.empty()<br />

status = “Selection is type: “ + document.selection.type<br />

}<br />

<br />

<br />

<br />

IE selection Object<br />

<br />

<br />

De-select after two seconds<br />

Delete selected text.<br />

<br />

Lorem ipsum dolor sit amet, consectetaur<br />

adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna<br />

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

ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit<br />

involuptate velit esse cillum dolore eu fugiat nulla pariatur.<br />

<br />

<br />

Methods<br />

clear()<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!