Home >Web Front-end >JS Tutorial >Cursor's post summary (use of Range)_javascript skills
Let’s talk about the common methods of TextRange first
collapse([bStart])
Move the insertion point of Range
bStart true (move to the beginning) false (move to the end)
findText (sText [, iSearchScope] [, iFlags])
Find sText in Range
iSearchScope starting position, search in negative direction
iFlags 2 (whole word match) 4 (case sensitive)
moveStart(sUnit [, iCount])
moveEnd(sUnit [, iCount])
Move the beginning or end of Range
sUnit character(word) word(word) sentence(sentence) textedit(Range)
iCount number of moves, default is 1
moveToPoint(iX, iY)
Move the cursor to coordinates (iX, iY)
pasteHTML(sHTMLText)
Replace in Range html
scrollIntoView([bAlignToTop])
Scroll to display in the current window
bAlignToTop true (Range is at the beginning of the window) false (Range is at the bottom of the window)
select()
Select Range
and then talk about some examples. You can also help to summarize it. It’s hard to find posts, haha
Set the cursor (qiushuiwuhen)
样式表滤镜实例
<script> function GetCursorPos(oTextArea) { s="~!@#$%^"; clipboardData.setData('text',s); oTextArea.focus(); document.execCommand('paste'); var ret=oTextArea.value.indexOf(s); document.execCommand('undo'); return ret; } </script>