¡@

Home 

javascript Programming Glossary: containerel

Persisting the changes of range objects after selection in HTML

http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html

document.createRange saveSelection function containerEl var range window.getSelection .getRangeAt 0 var preSelectionRange.. range.cloneRange preSelectionRange.selectNodeContents containerEl preSelectionRange.setEnd range.startContainer range.startOffset.. start range.toString .length restoreSelection function containerEl savedSel var charIndex 0 range document.createRange range.setStart..

Get caret position in contentEditable div

http://stackoverflow.com/questions/3972014/get-caret-position-in-contenteditable-div

Code function getCaretPosition editableDiv var caretPos 0 containerEl null sel range if window.getSelection sel window.getSelection..

replace innerHTML in contenteditable div

http://stackoverflow.com/questions/5595956/replace-innerhtml-in-contenteditable-div

http jsfiddle.net 2rTA5 2 Code function saveSelection containerEl var charIndex 0 start 0 end 0 foundStart false stop var sel.. i range if sel.rangeCount try traverseTextNodes containerEl sel.getRangeAt 0 catch ex if ex stop throw ex return start.. ex return start start end end function restoreSelection containerEl savedSel var charIndex 0 range rangy.createRange foundStart..

Insert link in contenteditable element

http://stackoverflow.com/questions/5605401/insert-link-in-contenteditable-element

function getLinksInSelection var selectedLinks var range containerEl links linkRange if window.getSelection sel window.getSelection.. for var r 0 r sel.rangeCount r range sel.getRangeAt r containerEl range.commonAncestorContainer if containerEl.nodeType 1 containerEl.. r containerEl range.commonAncestorContainer if containerEl.nodeType 1 containerEl containerEl.parentNode if containerEl.nodeName.toLowerCase..