Range 屬性
屬性 | 說明 | 回傳 |
---|---|---|
collapsed |
如果start以及end是在同一點上回傳true,不同為false |
Boolean |
commonAncestorContainer |
回傳涵蓋範圍,最外層標籤 |
String |
endContainer |
回傳標籤物件,使用tagName可察看標籤 |
Object |
endOffset |
回傳標籤內,最後一個字的位置 |
integer |
startContainer |
回傳標籤物件,使用tagName可察看標籤 |
Object |
startOffset |
回傳標籤內,第一個字的位置 |
integer |
Range 方法
方法 | 說明 | 回傳 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
cloneContents() |
複製 |
object |
||||||||||
cloneRange() |
複製選取範圍 |
Object |
||||||||||
collapse(Boolean) |
true = Range的開始位置,false = Range的結束位置 |
無 |
||||||||||
compareBoundaryPoints(type, rangeToCompare) |
|
Integer |
||||||||||
compareNode(nodeToCompare) |
nodeToCompare = 選擇的目標 功能和compareBoundaryPoints相同 |
回傳為Integer
|
||||||||||
comparePoint(nodeToCompare,offsetInsideNode) |
回傳Integer
|
|||||||||||
createContextualFragment(HTMLtext) |
將字串轉標籤物件 |
Element |
||||||||||
deleteContents() |
刪除目標內容 |
無 |
||||||||||
detach() |
離開選取範圍,並允許瀏覽器,以釋放資源 |
無 |
||||||||||
extractContents() |
用途可用來移動目標內容,完整移動 |
element |
||||||||||
insertNode(nodeToInsert) |
nodeToInsert = 要插入的標籤物件 |
無 |
||||||||||
intersectsNode(nodeToCheck) |
nodeToCheck = 目標 |
true = 選擇範圍有涵蓋到目標,包含選擇自己;false = 選擇沒有涵蓋到目標 |
||||||||||
isPointInRange(nodeToCheck,offsetInsideNode) |
(nodeToCheck = 目標.focusNode;offsetInsideNode =目標.focusOffset |
Boolean |
||||||||||
selectNode(node) |
目標自己本身 |
無 |
||||||||||
selectNodeContents(node) |
目標內容 |
無 |
||||||||||
setEnd(node,offsetInsideNode) |
node = 目標 ;offsetInsideNode = 位置int |
無 |
||||||||||
setStart(node,offsetInsideNode) |
node = 目標 ;offsetInsideNode = 位置int |
無 |
||||||||||
setEndAfter(node) |
選擇end位置之後節點 |
無 |
||||||||||
setEndBefore(node) |
選擇end位置之前節點 |
無 |
||||||||||
setStartAfter(node) |
選擇start位置之後節點 |
無 |
||||||||||
setStartBefore(node) |
選擇start位置之前節點 |
無 |
||||||||||
surroundContents(element) |
標籤物件包圍目標 |
無 |
||||||||||
toString() |
回傳選擇字串 |
String |