The isTextEdit Property


The isTextEdit Property

The 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

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

isTextEdit

           

x

x

x

x

 

Read-only

 

Type: Boolean

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.

graphics/05fig12.gif



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net