如何使用window.history.pushState' safely' [英] How can I use window.history.pushState 'safely'

查看:47
本文介绍了如何使用window.history.pushState' safely'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在支持的浏览器中使用 window.history.pushState()函数.不幸的是,我在Firefox上遇到错误:

I would like to use the window.history.pushState() function in supporting browsers. Unfortunately I'm getting an error on Firefox:

TypeError:history.pushState不是函数

TypeError: history.pushState is not a function

如何避免这种情况?

推荐答案

[try-catch]标记表示您已经知道答案了……(是否还有更具体的信息?)另一个可能性是检查 if(history.pushState)history.pushState({},document.title,location.href);

[try-catch] tag implies what you know the answer already... (is there anything more specific?) The other possibitity is to check if ( history.pushState ) history.pushState( {}, document.title, location.href );

这篇关于如何使用window.history.pushState' safely'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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