IE11 window.history.pushState"对象不支持属性或方法'pushState'

ton*_*oni 4 javascript html5 history pushstate internet-explorer-11

我在下面有这个简单的HTML代码.它在Chrome和IE11中的开发环境(Visual Studio 2010)中按预期工作(将SomeParam附加到url).当我把它放在网络服务器上的htm文件中时,它可以在Chrome中运行,但是在IE11中它给出了"对象不支持属性或方法'pushState'.我已经彻底搜索了这个并且只能发现pushState不是IE版本<= 9.0支持但IE10和IE11应该支持.
有没有人有任何想法?

<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>
Run Code Online (Sandbox Code Playgroud)

Luk*_*ard 9

如果您还没有这样做,请尝试将以下元标记添加到您的网页:

<meta http-equiv="x-ua-compatible" content="IE=edge">
Run Code Online (Sandbox Code Playgroud)

还要确保这是页面上的第一个元标记.

您是否在Intranet上运行此应用程序?如果是这样,IE11可能决定模拟旧版本的IE(使用F12开发者工具检查).上面的元标记应该阻止IE执行此操作并强制它以IE11模式呈现页面.