IE lose custom tag while sethtml

2019-01-29 10:46发布

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条回答
不美不萌又怎样
2楼-- · 2019-01-29 11:19

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.

查看更多
登录 后发表回答