IE11 window.history.pushState "The object does not support the property or method" pushState "

I have this simple html code below. It works as expected (adding? SomeParam to the URL) in my development environment (Visual Studio 2010) in both Chrome and IE11. When I put this in an htm file on a web server, it works in Chrome, but in IE11 it gives โ€œObject does not support the property or theโ€œ pushState โ€method. I searched for it completely and can only find that pushState is not supported in IE versions < = 9.0, but should be supported in IE10 and IE11.
Does anyone have any ideas?

<script language="javascript" type="text/javascript"> function test1() { try { window.history.pushState("abc", "", "/?SomeParam"); } catch (err) { alert(err.message); } } </script> <button id="button1" onclick="test1()">Test</button> 
+5
source share
1 answer

Try adding the following meta tag to your page if you have not already done so:

 <meta http-equiv="x-ua-compatible" content="IE=edge"> 

Make sure this is the first meta tag on the page.

Are you running this application on the intranet? If so, IE11 may decide to emulate an older version of IE (check this with the F12 Developer Tools). The above meta tag should stop IE from doing this and make it display the page in IE11 mode.

+9
source

All Articles