Search code examples
htmlinternet-explorerinternet-explorer-8innerhtmlinternet-explorer-11

innerHTML doesn't work in IE11 and IE8


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


Solution

  • 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");