IE6 和 7 的 innerHTML 问题
IE6和7的innerHTML问题
我在我开发的应用程序中使用了ajax,但是IE6和IE7存在问题,它们不支持innerHTML。必须使用什么来解决此问题并实现跨浏览器兼容?
示例代码如下所示。
function showFAQ(src, target){
xhr.onreadystatechange=function(){
if(xhr.readyState == 4 && xhr.status == 200){
document.getElementById('resultDiv').innerHTML=xhr.responseText;
}
}
str = "?action=get&request="+src;
xhr.open("GET", "./requests/data.php"+encodeURI(str), true);
xhr.send();
}
在FireFox、IE8等主流浏览器中工作正常。只是问题出在 IE6 和 7 上。
任何帮助/建议将不胜感激。
谢谢
IE6 and 7 issue with innerHTML
I have used ajax in the application i have develop, but there are issues with IE6 and IE7, they doesn't support innerHTML. What must be used to fixed this issue and to be a cross browser compatible?
the sample code looks like this.
function showFAQ(src, target){
xhr.onreadystatechange=function(){
if(xhr.readyState == 4 && xhr.status == 200){
document.getElementById('resultDiv').innerHTML=xhr.responseText;
}
}
str = "?action=get&request="+src;
xhr.open("GET", "./requests/data.php"+encodeURI(str), true);
xhr.send();
}
In FireFox, IE8 and other major browsers works fine. Just the problem is with IE6 and 7.
Any help/advice will be appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
IE 无法使用innerHTML 更新只读元素...也请考虑这一点..:)
IE cannot update readonly elements using innerHTML... consider this too.. :)
尝试
Update
尝试添加
之后
Try
Update
Try adding
after
从 IE5 开始支持 innerHTML。我认为你的问题是 xmlhttprequest 对象的使用。该功能仅从 IE7 开始受支持。但是,您可以将 ActiveXObject 作为 Stealthyninja 的代码使用。
innerHTML is supported as of IE5. I think you problem is the use of the xmlhttprequest object. That one is only supported as of IE7. You can however ActiveXObject as stealthyninja's code uses.