IE lose custom tag while sethtml

依然范特西╮ 提交于 2019-12-13 11:32:15

问题


This following Code Running in FF & IE

TempNode= CKEDITOR.dom.element.createFromHtml("<span></span>");
TempNode.setHtml("<p>test</p>");

But below mentioned code losing user defined Tags In IE (FF Works Fine)

TempNode= CKEDITOR.dom.element.createFromHtml("<span></span>");
TempNode.setHtml("<myTag>test</myTag>");

Also same problem with *appendHtml()*

My Exact Requirement is :

 Element.setHtml(AnotherElement.getHtml());

original value in AnotherElement.getHtml() is:

<P><mytag id="test_39878" data-cke-expando="undefined">some. text</myTag></P>

after Element.sethtml() it containing value is :

<P>some. tex</MYTAG></P>

回答1:


If you want to use your own tags in IE you've got to create them first. This is the same situation that we've got with HTML5 tags.

So before setting HTML with <myTag>, create it CKEDITOR.document.createElement( 'mytag' ) just to let IE know it exists.

BTW. Remember that elements must be created in the same document in which they'll be used. So if you want to insert them into editor's content, then create them in editor's document (e.g. CKEDITOR.instances.editor1.document). Otherwise IE will throw an error.



来源:https://stackoverflow.com/questions/12967695/ie-lose-custom-tag-while-sethtml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!