The isTextEdit PropertyThe isTextEdit property returns true if you can create an Internet Explorer TextRange object using its content. You can see the support for this property in Table 5.31. Table 5.31. The isTextEdit Property
We'll see more on text ranges in Chapter 11; they let you work with text grouped together into an object. Here's a preview, where I'm using a text range to rewrite the text in a <DIV> element, and using the isTextEdit : (Listing 05-15.html on the web site)<HTML> <HEAD> <TITLE> Using Text Ranges </TITLE> <SCRIPT LANGAUGE="JavaScript"> <!-- function replaceText() { if(document.body.isTextEdit){ var range = document.body.createTextRange() range.moveToElementText(div1) range.pasteHTML("Here is the replacement text!") } } // --> </SCRIPT> </HEAD> <BODY> <H1>Using Text Ranges</H1> <INPUT TYPE=BUTTON VALUE="Click Me!" onclick="replaceText()"> <BR> <BR> <DIV ID="div1" STYLE="font-family:Arial, sans-serif; font-weight:bold"> Click the button to replace all this text. </DIV> </BODY> </HTML> You can see the results in Figure 5.12, where I've clicked the button and replaced the original text with new text. More on text ranges in Chapter 11. Figure 5.12. Using the isTextEdit property.
|