I've successfully done this for IE7. FF, no dice.
any ideas? Thanks!
var range= window.getSelection().getRangeAt(0);
alert('Current position: '+range.startOffset+' inside '+range.startContainer);
range.setStart(newParent, textOffset);
range.setEnd(newParent, textOffset);
Here's my solution to the OpenWYSIWYG for moving the cursor to a specified position in FireFox, after setting focus to 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);
}
}
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.