4

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

Community
  • 1
  • 1
OmiD
  • 231
  • 2
  • 4
  • 14
  • Going to guess that `mainForm:table_1` is a `` element? If so, try selecting a parent element of the table and replace the entire table.
    – Niet the Dark Absol Sep 22 '14 at 08:15
  • yes you are right , it is a table . I try to do that and how about second part of my question ? how can I add a string to url with something like pushstate that work with ie8 and ie9 too ? thanks for your answer – OmiD Sep 22 '14 at 08:43

2 Answers2

6

IE9 and below doesn't support pushState. For unsupported browsers use history API. and also find some more list of polyfills here.

  • yes you are right it doesn't work, but isn't any way to do so with native javascript or jquery ? with out using history API – OmiD Sep 22 '14 at 08:48
  • 1
    @OmiD You could just stop supporting outdated/obsolete browsers. It's time we stopped pandering to people who refuse to update - especially since doing so pretty much requires manually and deliberately (and therefore, maliciously to us) disabling Windows Update. – Niet the Dark Absol Sep 22 '14 at 08:54
2

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");
omid haghighatgoo
  • 322
  • 1
  • 3
  • 16