Get and set carriage position in contentEditable iframe (Firefox)

I have successfully done this for IE7. FF, no dice.

any ideas? Thanks!

+4
source share
2 answers
var range= window.getSelection().getRangeAt(0); alert('Current position: '+range.startOffset+' inside '+range.startContainer); range.setStart(newParent, textOffset); range.setEnd(newParent, textOffset); 
+3
source

Here is my OpenWYSIWYG solution for moving the cursor to the specified position in FireFox after setting the focus on the editor:

 focusEditor: function (n) { var editor = this.getEditorWindow(n); if (WYSIWYG_Core.isFF) { editor.document.body.focus(); try { var sel = this.getSelection(n); var range = sel.getRangeAt(0); range.setStart(sel.anchorNode.childNodes[0], 1); range.setEnd(sel.anchorNode.childNodes[0], 0); sel.addRange(range); } catch (err) { //alert(err.description); } } }, 
+2
source

All Articles