本文介绍了为什么html的工作,而不是innerHTML的或使用appendChild的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想Ajax响应添加到一个div(它的HTML code,表格,表单等)。

I am trying to add an ajax response to a div (it's htmlcode, tables, forms etc).

在FF innerHTML的作品完美,但在IE它给了我一个未知的错误。

In FF innerHTML works perfectly, but in IE it gives me an unknown error.

我试过很多的东西,但我只拿到了,当我加入jQuery的它工作,跑了我想要的code插入,在div的html的方法

I tried lot's of stuff, but I only got it working when I added jQuery and ran the .html method on the div I want the code inserted into.

有人在乎解释为什么这个工程,而不是一个简单的innerHTML?我试图寻找在html的code,但我想我不是伟大的JS,因为我不知道这是什么做:(

Anyone care to explain why this works and not a simple innerHTML? I tried looking at the .html code, but I guess I am not the great at js because I didn't understand what it was doing :(

谢谢!

推荐答案

若干的记录(的 | |的 | ) .innerHTML错误

IE has several documented (pre | table (thead, tbody, tr, tfoot) | div | select) .innerHTML bugs.

这样的库,如 jQuery的抽象掉这些漏洞为您申请时需要的IE浏览器的解决方法。

Thus libraries like jQuery abstract away those bugs for you by applying workarounds where needed for IE.

至于你具体的错误......没有看到code这是很难说。

As for your specific error... without seeing the code it is hard to tell.

设置 .innerHTML 在pre的,的某种的div的,选择的(如果它失败了,失败默默),但设置 .innerHTML 上(在IE浏览器的某些版本),实际上将抛出一个错误/异常。某些表格元素

Setting the .innerHTML on pre's, certain div's, select's (if it does fail, will fail silently) but setting the .innerHTML on certain table elements (in certain versions of IE) will actually throw an error/exception.

注意的:与设定的 .innerHTML A DIV的问题是非常具体的条件,只发生在IE6和放大器; IE7。

Note: The issue with setting the .innerHTML of a div is very specific in condition and only occurs in IE6 & IE7.

这篇关于为什么html的工作,而不是innerHTML的或使用appendChild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 15:20