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 1 ✦ Generic HTML Element Objects (Chapter 15)<br />

Listing 15-14: Using the parentTextEdit Property<br />

<br />

<br />

parentTextEdit Property<br />

<br />

P {cursor:hand}<br />

<br />

<br />

function selectChunk() {<br />

var chunk, range<br />

for (var i = 0; i < document.forms[0].chunk.length; i++) {<br />

if (document.forms[0].chunk[i].checked) {<br />

chunk = document.forms[0].chunk[i].value<br />

break<br />

}<br />

}<br />

var x = window.event.clientX<br />

var y = window.event.clientY<br />

if (window.event.srcElement.parentTextEdit) {<br />

range = window.event.srcElement.parentTextEdit.createTextRange()<br />

range.collapse()<br />

range.moveToPoint(x, y)<br />

range.expand(chunk)<br />

range.select()<br />

}<br />

}<br />

<br />

<br />

<br />

<br />

Choose how much of the paragraph is to be selected when you click anywhere in<br />

it:<br />

Character<br />

Word<br />

Sentence<br />

.<br />

<br />

<br />

Lorem ipsum dolor sit amet, consectetaur adipisicing elit, sed do eiusmod tempor<br />

incididunt ut labore et dolore magna aliqua. Ut enim adminim veniam, quis<br />

nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.<br />

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

fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in<br />

culpa qui officia deserunt mollit anim id est laborum.<br />

<br />

<br />

<br />

39<br />

elementObject.parentTextEdit

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

Saved successfully!

Ooh no, something went wrong!