InnerHTML does not work in IE11 and IE8

I use these codes to refresh parts 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 does not work in IE8 and IE11

I read these links: .InnerHTML Does not work properly in Internet Explorer as well as document.getElementById (). innerHTML does not work with "Unknown error" in IE

but my problem is that I cannot easily change another part of my code due to dynamic generation.

1) Is there a way that I can only do with this part of my code to solve the IE problem?

2), and also I need an alternative for:

 window.history.pushState() 

which does not work in IE8 and IE9

+4
source share
3 answers

for the first part of your question do the following:

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

and for the second part of your question, like @JITHIN PV, you should use history.js

you can easily use it as follows:

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

IE9 and below do not support pushState. For unsupported browsers, use the history API . and also find another list of polypolnies here .

+6
source

IE 11 does not seem to update the element if the new content installed on innerHTML matches its actual content.
My problem was that in <img src = 'some_url' ...> the string 'some_url' was the same even if its contents were changed.
To solve this problem, I added milliseconds at the end of some_url so that it becomes: <img src = 'some_url & time =' + new Date (). GetTime () ...>

0
source

Source: https://habr.com/ru/post/1203119/


All Articles