Firefox与IE:innerHTML处理 [英] Firefox vs. IE: innerHTML handling

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

问题描述

经过几个小时的调试,在FireFox中,在FireFox中,DOM的innerHTML反映了标记中的实际内容,但是在IE中,innerHTML反映了用户或动态()即通过Javascript)。

After hours of debugging, it appears to me that in FireFox, the innerHTML of a DOM reflects what is actually in the markup, but in IE, the innerHTML reflects what's in the markup PLUS any changes made by the user or dynamically (i.e. via Javascript).

有其他人发现这是真的吗?任何有意思的工作,以确保两者都有相同的方式?

Has anyone else found this to be true? Any interesting work-arounds to ensure both behave the same way?

推荐答案

我同意Pat。在游戏的这一点上,编写自己的代码来处理跨浏览器的兼容性,给出可用的JavaScript框架并没有太大的意义。有一个几乎任何味道的框架(一些非常小的),他们专注于真正抽象出浏览器之间的所有差异。他们正在做更多的测试,而不是你可能。

I agree with Pat. At this point in the game, writing your own code to deal with cross-browser compatibility given the available Javascript frameworks doesn't make a lot of sense. There's a framework for nearly any taste (some really quite tiny) and they've focused on really abstracting out all of the differences between the browsers. They're doing WAY more testing of it than you're likely to.

像jQuery或雅虎的YUI(想想有多少人在一天中打了Yahoo Javascript,各种浏览器)只是比您或我想出的任何代码段更经过路测。

Something like jQuery or Yahoo's YUI (think how many people hit the Yahoo Javascript in a day and the variety of browsers) is just way more road-tested than any snippet you or I come up with.

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

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