| javascript Programming Glossary: restoreselectionPersisting the changes of range objects after selection in HTML http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html  this Demo http jsfiddle.net WeWy7 3 Code var saveSelection restoreSelection if window.getSelection document.createRange saveSelection function.. return start start end start range.toString .length  restoreSelection function containerEl savedSel var charIndex 0 range document.createRange.. start start end start selectedTextRange.text.length  restoreSelection function containerEl savedSel var textRange document.body.createTextRange.. 
 Get Image dimensions using Javascript during file upload http://stackoverflow.com/questions/2865017/get-image-dimensions-using-javascript-during-file-upload 
 Insert text at cursor in a content editable div http://stackoverflow.com/questions/2920150/insert-text-at-cursor-in-a-content-editable-div  in a variable and then pass that variable into restoreSelection to restore the selection after hiding the context menu and before.. return document.selection.createRange return null function restoreSelection range if range if window.getSelection  sel window.getSelection.. 
 contenteditable selected text save and restore http://stackoverflow.com/questions/4687808/contenteditable-selected-text-save-and-restore  return document.selection.createRange return null function restoreSelection range if range if window.getSelection  sel window.getSelection.. document.getElementById textInserter .style.display none restoreSelection selRange document.getElementById test .focus insertTextAtCursor.. 
 replace innerHTML in contenteditable div http://stackoverflow.com/questions/5595956/replace-innerhtml-in-contenteditable-div  el.innerHTML.replace 0 9 ig font color 'red' 1 font  rangy.restoreSelection savedSel  div contenteditable true id pad onkeyup formatText.. if ex stop  throw ex   return start start end end function restoreSelection containerEl savedSel var charIndex 0 range rangy.createRange.. 
 Insert link in contenteditable element http://stackoverflow.com/questions/5605401/insert-link-in-contenteditable-element  return document.selection.createRange return null function restoreSelection savedSel if savedSel if window.getSelection  sel window.getSelection.. 
 Editing Iframe Content in IE - problem in maintaining text selection http://stackoverflow.com/questions/5767037/editing-iframe-content-in-ie-problem-in-maintaining-text-selection  iframeWindow before the editor document loses focus and restoreSelection iframeWindow sel after it regains focus. Otherwise I'd suggest.. which uses hidden marker elements. var saveSelection restoreSelection if window.getSelection IE 9 and non IE saveSelection function.. i len i  ranges.push sel.getRangeAt i   return ranges restoreSelection function win savedSelection var sel win.getSelection sel.removeAllRanges.. 
 How to get caret position within contenteditable div with html child elements? http://stackoverflow.com/questions/5951886/how-to-get-caret-position-within-contenteditable-div-with-html-child-elements  saveSelection before doing whatever you need to do and restoreSelection afterwards. If you are changing the content I'd suggest using.. save restore selection module . var saveSelection restoreSelection if window.getSelection IE 9 and non IE saveSelection function.. i len i  ranges.push sel.getRangeAt i   return ranges restoreSelection function savedSelection var sel window.getSelection sel.removeAllRanges.. 
 |