JavaScript Reference/Javascript Objects/TextRange

Материал из Web эксперт
Версия от 08:22, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"TextRange" Example

    
<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">
<p id="myP">This is some text in the document inside a p element</p>
<button onclick="displayText();">Display the text range</button>
</body>
</html>



"TextRange" JavaScript Methods

+----------------+--------------------------------------------------------------+
| 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                                                   |
+----------------+--------------------------------------------------------------+



"TextRange" JavaScript Properties

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



"TextRange" Syntax and Note

Note:
Access to text created using the createRange() and 
createTextRange() methods.
    
Syntax:
    
textRangeName = document.all.elementID.createTextRange()
textRangeName = document.selection.createRange()
textNameRange.memberName