ckeditor javascript code EditorInstance.document.getSelection().getStartElement() working on Firefox but Not Working in IE

StackOverflow https://stackoverflow.com/questions/12930447

Question

Node JAVASCRIPT CODE:

Editor= CKEDITOR.instances['ckeditor1'];


getElem=Editor.document.getSelection().getStartElement();
getElem.setHtml("<Element6>SomeText</Element6>");

Working On : FireFox

not working On : Internet Explorer

The Error is :`'Editor.document.getSelection() is null or not an object

how do i get Parent node of cursor position in IE?

DATA ON CKEDITOR:

<Element1>SomeText<Element2>SomeText</Element2>

<Element3>Some**[suppose Cursor Is Here]** Text </Element3>

</Element1>

Required Result:

 <Element1>SomeText<Element2>SomeText</Element2><Element3> 

<Element6>SomeText</Element6>

</Element3></Element1>
Was it helpful?

Solution

Following code Working well.. Thanks to * Reinmar*

Editor= CKEDITOR.instances['ckeditor1'];
Editor.focus();
getElem=Editor.document.getSelection().getStartElement();
getElem.setHtml("<Element6>SomeText</Element6>");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top