IE11 window.history.pushState" Object不支持属性或方法'pushState' [英] IE11 window.history.pushState "Object doesn't support property or method 'pushState'

查看:417
本文介绍了IE11 window.history.pushState" Object不支持属性或方法'pushState'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

有没有人有任何想法?

I have this simple html code below. It works as expected (appending ?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 the web server, it works in Chrome, but in IE11 it gives "Object doesn't support property or method 'pushState'. I've searched this thoroughly 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>


推荐答案

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

Try adding the following meta tag to your page, if you haven't done so already:

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

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

Ensure also that this is the first meta tag on the page.

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

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

这篇关于IE11 window.history.pushState&quot; Object不支持属性或方法'pushState'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆