Popstate 不适用于某些浏览器

utt*_*ani 5 javascript jquery

我使用的代码如下:

if (window.history && window.history.pushState) {
    window.history.pushState('forward', null, './#forward');
    $(window).on('popstate', function () {
        window.location.href = "https://www.google.com/";   
    });
}
Run Code Online (Sandbox Code Playgroud)

我想使用“推送状态”在 URL 中添加 #forward,然后如果用户单击浏览器后退按钮,我想重定向到另一个链接。

工作:它在 chrome 中工作,但不能与“CANARY”搜索引擎一起工作。请帮我弄清楚这个问题。提前致谢。