JavaScript Reference/Javascript Objects/TextRange

Материал из Web эксперт
Перейти к: навигация, поиск

"TextRange" Example

   <source lang="javascript">
   

<html> <head> <script language="javascript"> function displayText(){

   textRange = document.all.myBody.createTextRange();
   textRange.moveToElementText(myP);
   var m = textRange.text;
   alert(m); 

} </script></head> <body id="myBody">

This is some text in the document inside a p element

<button onclick="displayText();">Display the text range</button> </body> </html>


     </source>
   
  


"TextRange" JavaScript Methods

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | JavaScript |collapse compareEndPoints | | Methods |duplicate execCommand | | |expand findText | | |getBookmark getBoundingClientRect | | |getClientRects inRange | | |isEqual move | | |moveEnd moveStart | | |moveToBookmark moveToElementText | | |moveToPoint parentElement | | |pasteHTML queryCommandEnabled | | |queryCommandIndeterm queryCommandState | | |queryCommandSupported queryCommandValue | | |scrollIntoView select | | |setEndPoint | +----------------+--------------------------------------------------------------+

     </source>
   
  


"TextRange" JavaScript Properties

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | JavaScript |boundingHeight boundingLeft | | Properties |boundingTop boundingWidth | | |htmlText offsetLeft | | |offsetTop text | +----------------+--------------------------------------------------------------+

     </source>
   
  


"TextRange" Syntax and Note

   <source lang="javascript">

Note: Access to text created using the createRange() and createTextRange() methods.

Syntax:

textRangeName = document.all.elementID.createTextRange() textRangeName = document.selection.createRange() textNameRange.memberName


     </source>