Javascript 黑客保留历史。点击状态ie8-9

Javascript 黑客保留历史。点击状态ie8-9,javascript,jquery,internet-explorer,internet-explorer-8,Javascript,Jquery,Internet Explorer,Internet Explorer 8,在大多数现代浏览器上,我可以使用: history.pushState({}, 'Our Work','/url/path/'); 显然IE不支持这一点,但我想知道为什么我的简单破解不起作用 history = { pushState : function(state,title,url) { window.location = url; } }; 我也试过: window.history = { pushState : function(state,

在大多数现代浏览器上,我可以使用:

history.pushState({}, 'Our Work','/url/path/');
显然IE不支持这一点,但我想知道为什么我的简单破解不起作用

history = {
    pushState : function(state,title,url) {
        window.location = url;
    }
};
我也试过:

window.history = {
    pushState : function(state,title,url) {
        window.location = url;
    }
};
但我得到了一个“未找到成员”属性

这在IE8中可能吗

我真的不想为这个简单的hack包含一个完整的库,但这很奇怪,因为添加:

if (!window.console) {
    console = {
        log: function() {},
        error: function() {}
    };
}
修复我的控制台日志


任何帮助都会很好

这是因为历史对象确实存在,不能完全替换它

但您可以向其添加其他方法

所以设置

history.pushState = function(state,title,url){alert(url);};

这就行了。

我看不出有什么理由不起作用。嗯