将 html 插入 yahoo 的 YUI 富文本编辑器
我正在尝试将 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&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);
有人知道为什么吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据编辑器对象的设置,一些标签会被清理。
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.