function getCaret(textbox) { var control = document.activeElement; textbox.focus(); var rang = document.selection.createRange(); rang.setEndPoint("StartToStart",textbox.createTextRange()) control.focus(); return rang.text.length; } function setCaret(textbox,pos) { try { var r =textbox.createTextRange(); r.moveStart('character',pos); r.collapse(true); r.select(); } catch(e) {} } function selectLength(textbox,start,len) { try { var r =textbox.createTextRange();
document.onclick =function(){ var oSource = window.event.srcElement; if(oSource.tagName!="DIV") returnfalse; var sel = document.selection; if (sel!=null) { var rng = sel.createRange(); if (rng!=null) rng.pasteHTML("插入文字"); } }
ID="oDiv" ATTRIBUTE1="true" ATTRIBUTE2="true" onclick="alert('click');" onmouseover="this.style.color='#0000FF';" onmouseout="this.style.color='#000000';" > This is a sample DIV element.
collapse([bStart]) Collapse the selection and move the insertion point of Range bStart true(move to the beginning, default) false(move to End)
expand(sUnit) Expand the selection so that the selection included in the unit is included
findText(sText [, iSearchScope] [, iFlags]) in Range Search sText iSearchScope starting position, negative direction search iFlags 1 (search backward) 2 (whole word match) 4 (case sensitive)
moveStart(sUnit [, iCount]) moveEnd(sUnit [, iCount]) Move the beginning or end of the Range sUnit character(word) word(word) sentence(sentence) textedit(Range) iCount The number of moves, the default is 1
moveToPoint(iX, iY) Move the cursor to coordinates (iX, iY)
pasteHTML(sHTMLText) Replace the html in Range
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)
Access form elements document.all("txt").focus(); document.all("txt").select();
Form Command document.execCommand
FORM COOKIE document.cookie
Menu event document.oncontextmenu
Create element document.createElement("SPAN");
Get the element based on the mouse: document.elementFromPoint(event.x,event.y).tagName=="TD document.elementFromPoint (event.x,event.y).appendChild(ms)
Form images document.images[index]
Form event binding document.onmousedown=scrollwindow;
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn