IE在sethtml时会丢失自定义标签 [英] IE lose custom tag while sethtml

查看:353
本文介绍了IE在sethtml时会丢失自定义标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在FF& IE

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

但是下面提到的代码丢失用户定义的标签在IE >

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>");

同样的问题* appendHtml() strong>

我的确切要求是

 Element.setHtml(AnotherElement.getHtml());

AnotherElement.getHtml()中的原始值是

<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>


推荐答案

如果您想在IE中使用自己的标签必须先创建它们。

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.

因此,在使用< myTag> ,创建 CKEDITOR.document.createElement('mytag')只是为了让IE知道它存在。

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

BTW。请记住,元素必须在使用它们的同一文档中创建。因此,如果要将其插入编辑器的内容,请在编辑器的文档中创建它们(例如 CKEDITOR.instances.editor1.document )。否则IE会抛出一个错误。

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.

这篇关于IE在sethtml时会丢失自定义标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆