innerHTML破坏了xhtml [英] innerHTML mangles the xhtml

查看:68
本文介绍了innerHTML破坏了xhtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当使用innerHTML插入xhtml时,IE5 +完全破坏了xhtml。

例如,它从属性中删除了引号。它还可以做其他

荒谬的事情,例如< div>它会插入嵌入的

style =" DISPLAY:BLOCK"!这是一个记录在案的功能,你可以在

msdn中找到。


有没有办法禁用这个非常令人震惊的功能?

解决方案



oo ** ****@yahoo.co.uk 写道:

使用innerHTML插入xhtml IE5 +完全破坏了xhtml。
例如它删除了引号来自属性。它还可以做其他类似于< div>的荒谬事情。它会插入嵌入的
style =" DISPLAY:BLOCK"!这是一个文档功能,你可以在
msdn中找到。

有没有办法禁用这个相当令人震惊的功能?




众所周知,IE无法将XHTML作为真正的XML处理,它所能做的就是将它视为HTML。 innerHTML正在做HTML中允许的内容,但不是XHTML中的
所以你只有一个理由可以避免使用XHTML,请参阅

< http:// www。 hixie.ch/advocacy/xhtml>


-


Martin Honnen
http://JavaScript.FAQTs.com/




IE可以完美呈现xhtml,否则我们就不会受到web标准合规性的欢迎,除了xhtml只是

干净的html无论如何。也许我误解了你的观点你能详细说明吗?


如果我手动将相同的xhtml放到页面中它会完美呈现,

当我把它通过innerHTML IE时故意改变之前的标记

来渲染。当然,IE使用相同的引擎来显示我从服务器发送的原始

xhtml,就像它渲染innerHTML一样?声音

像innerHTML对我和许多需要使用的网页开发人员来说都是无用的。

xhtml。


< blockquote>我做了更多测试。如果我在div的innerHTML上做一个alert()

,其中包含正常的静态xhtml然后它显示它被破坏了

表明innerHTML不是问题而是IE'解释

x / html可能是你的意思。


如果IE在渲染之前解析所有结构元素以适合自己的

渲染引擎难怪它比Firefox更慢。



When using innerHTML to insert xhtml IE5+ mangles the xhtml completely.
For example it removes the quotes from attributes. It also does other
ridiculous things like on a <div> it will insert the enbedded
style="DISPLAY:BLOCK"! This is a documented feature you can find in
msdn.

Is there a way to disable this quite appalling feature?

解决方案



oo******@yahoo.co.uk wrote:

When using innerHTML to insert xhtml IE5+ mangles the xhtml completely.
For example it removes the quotes from attributes. It also does other
ridiculous things like on a <div> it will insert the enbedded
style="DISPLAY:BLOCK"! This is a documented feature you can find in
msdn.

Is there a way to disable this quite appalling feature?



IE is known not to be able to handle XHTML as real XML, all it can do is
treat it as HTML. innerHTML is doing stuff which is allowed in HTML but
not in XHTML so you have just one more reason to avoid using XHTML, see
<http://www.hixie.ch/advocacy/xhtml>

--

Martin Honnen
http://JavaScript.FAQTs.com/



IE can render xhtml perfectly, otherwise we wouldn''t be having the
welcome surge of web standards compliance, and besides xhtml is just
clean html anyway. Maybe I misunderstand your point can you elaborate?

If I put the same xhtml into the page manually it renders perfectly,
when I put it through innerHTML IE deliberately alters the markup prior
to rendering. Surely IE uses the same engine to display the original
xhtml I send from the server as it does to render innerHTML? Sounds
like innerHTML is useless to me and many web developers who need to use
xhtml.


I''ve done more testing. If I do an alert() on the innerHTML of a div
which contains normal static xhtml then it displays it mangled which
suggests that innerHTML is not the problem but IE''s interpretation of
x/html is the problem which is probably what you meant.

If IE parses all structure elements prior to rendering to suit its own
rendering engine then no wonder it is slower than the likes of Firefox.


这篇关于innerHTML破坏了xhtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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