我正在通过润滑脂脚本/ opera扩展名将以下代码注入网页中以捕获history.pushState命令,因此无论何时触发它我都可以进行一些处理,但仍然允许pushState命令随后继续.
(function(history){
var pushState = history.pushState;
history.pushState = function(state) {
if (typeof history.onpushstate == "function") {
history.onpushstate({state: state});
}
alert('pushstate called')
return pushState.apply(history, arguments);
}
})(window.history);
该代码在FF4和Chrome中正常运行,但是在Opera 11中,如果页面调用了history.replaceState命令,则会出现以下错误:
Uncaught exception: TypeError: ‘window.history.replaceState’ is not a function
有谁知道我该如何解决以上代码,使其与Opera以及Chrome和Firefox一起使用?
解决方法:
在Opera 11.00,修订版1156中,支持的历史记录API是这些
>>> history.
back, current, forward, go, length, navigationMode
完整的HTML5 history API尚未包含在Opera 11.00中.通常,如果您想发现,探索受支持的内容,则可以轻松使用Web开发人员工具dragonfly的控制台方式.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。