Unable to get property 'createRange' of undefined or null reference in IE 11

935 Views Asked by At

There is functionality to find the caret(^) symbol in Telerik editor, I have searched over internet , i found few links ,they recommended to replace getSelection() instead of selection

var range = editor.get_document().getSelection().createRange();

but unfortunatly it is not working.

Actual code

   var range = editor.get_document().selection.createRange();
            var oRange = range.duplicate();
            oRange.collapse(false);
            if (oRange.findText("^")) {
                oRange.select();
            }
            else {
                editor.set_html("");
                editor.set_html(currentHtml);
                oRange.findText("^")
                oRange.select();
            }

error :Unable to get property 'createRange' of undefined or null reference

Updated code :

  var range = editor.get_document().getSelection().createRange();
                var oRange = range.duplicate();
                oRange.collapse(false);
                if (oRange.findText("^")) {
                    oRange.select();
                }
                else {
                    editor.set_html("");
                    editor.set_html(currentHtml);
                    oRange.findText("^")
                    oRange.select();
                }

Error: Object doesn't support property or method 'createRange' how can fix it.

0

There are 0 best solutions below