将 html 插入 yahoo 的 YUI 富文本编辑器

发布于 2024-09-25 20:41:35 字数 1003 浏览 0 评论 0原文

我正在尝试将 HTML 插入到 YUI 富文本编辑器中。如果我使用简单的 HTML 片段,该代码可以工作,但如果我使用更复杂的东西(例如尝试嵌入一个对象),那么它就会失败。

编辑

失败 - 仅适用于 FF 浏览器

例如 - 这有效:

var html = '<div><b><u>Hello world!</u></b></div>';
myEditor.execCommand('inserthtml', html);

但这不起作用:

var html = '<div><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/OVXIh4q-OmM?fs=1&amp;hl=en_GB&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/OVXIh4q-OmM?fs=1&amp;hl=en_GB&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></div>';

myEditor.execCommand('inserthtml', html);

有人知道为什么吗?

I am trying to insert HTML into the YUI rich text editor. The code works if I use simple HTML snippets, but if I use something more complicated (e.g. try to embed an object), then it fails.

Edit

Fails - only for FF browser

For example - this works:

var html = '<div><b><u>Hello world!</u></b></div>';
myEditor.execCommand('inserthtml', html);

But this dosen't work:

var html = '<div><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/OVXIh4q-OmM?fs=1&hl=en_GB&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/OVXIh4q-OmM?fs=1&hl=en_GB&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></div>';

myEditor.execCommand('inserthtml', html);

Does anyone know why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千紇 2024-10-02 20:41:35

根据编辑器对象的设置,一些标签会被清理。

YUI Rich Editor + invalidHTML + style 解释了“invalidHTML”概念并提供了一些示例代码解释一下。

Some tags get cleaned up, according the editor object's settings.

YUI Rich Editor + invalidHTML + style explains the "invalidHTML" concept and has some example code to explain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文