innerHTML在IE11和IE8中不起作用 [英] innerHTML doesn't work in IE11 and IE8

查看:794
本文介绍了innerHTML在IE11和IE8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用这些代码刷新我的页面的一部分:

  var container = document.getElementById(mainForm:table_1 ); 
var content = container.innerHTML;
container.innerHTML = content;

container.innerHTML在firefox和chrome
中运行良好,但在IE8中不起作用和IE11



我读过这些链接:
InnerHTML在Internet Explorer中无法正常工作



>但我的问题是,由于动态生成,我无法轻易更改代码的其他部分。



<1>有没有什么办法可以做到我的代码的这些部分来解决IE问题?
$ b $ 2我也需要一个替代方案:

 window.history.pushState()

在IE8和IE9中工作

解决你可以这样做:

  var container = document.getElementById(mainForm :TABLE_1\" )parentNode; 
var content = container.innerHTML
container.innerHTML = content;

以及作为@JITHIN PV的问题的第二部分,您必须使用history.js



您可以像这样轻松使用它:

  var History = window.History ; 
History.enabled;
History.pushState(object or string,object or string,object or string);


I use these codes for refreshing a part of my page :

var container = document.getElementById("mainForm:table_1");
var content = container.innerHTML;
container.innerHTML= content;

container.innerHTML worked well in firefox and chrome but it doesn't work in IE8 and IE11

I've read these links : .InnerHTML Not working properly in Internet Explorer and document.getElementById().innerHTML fails with 'Unknown Error' in IE

but my problem is that I can't change the other part of my code easily due to of dynamically generation.

1) Is there any way that I can do just with these part of my code to solve IE problem ?

2) and also i need an alternative for :

window.history.pushState()

which doesn't work in IE8 and IE9

解决方案

for first part of your question do this :

  var container = document.getElementById("mainForm:table_1").parentNode;
  var content = container.innerHTML
  container.innerHTML= content;

and for second part of your question as @JITHIN PV said you must use history.js

you can easily use it like this :

var History = window.History;
History.enabled ;
History.pushState("object or string", "object or string", "object or string");

这篇关于innerHTML在IE11和IE8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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