diff --git a/src/js/util.js b/src/js/util.js index f4581f5..4d96c46 100644 --- a/src/js/util.js +++ b/src/js/util.js @@ -27,20 +27,28 @@ function getSelectionStart(doc) { } function placeCaretAtNode(doc, node, before) { + var isIE = /*@cc_on!@*/false || !!document.documentMode; if (doc.getSelection !== undefined && node) { - var range = doc.createRange(), - selection = doc.getSelection(); + if (!isIE) { + var range = doc.createRange(), + selection = doc.getSelection(); - if (before) { - range.setStartBefore(node); - } else { - range.setStartAfter(node); - } + if (before) { + range.setStartBefore(node); + } else { + range.setStartAfter(node); + } - range.collapse(true); + range.collapse(true); - selection.removeAllRanges(); - selection.addRange(range); + selection.removeAllRanges(); + selection.addRange(range); + } else { + var rangeObj = document.body.createTextRange(); + rangeObj.moveToElementText(node); + rangeObj.moveStart('character', 1); + rangeObj.select(); + } } }