jjzjj

onpopstate

全部标签

javascript - window.onpopstate, event.state == null?

我已经阅读了关于StackOverflow的几个问题/答案并用Google搜索了这个问题,我似乎无法让event.state返回任何东西,除了null.我知道它不适用于jQuery事件,但是当我这样做时:window.onpopstate=function(e){console.log(e.state)}与jQuery.ajax成功调用类似的东西history.pushState({lastUrl:data.State},data.Title,data.UrlKey);Chrome(v19)或Firefox(v12)都没有返回null?我错过了什么吗?只是没有完全实现吗?

javascript - 如何在页面加载时忽略 window.onpopstate?

我正在玩window.onpopstate,有件事让我有点恼火:Browserstendtohandlethepopstateeventdifferentlyonpageload.ChromeandSafarialwaysemitapopstateeventonpageload,butFirefoxdoesn't.source我测试过,是的,在Chrome和Safari5.1+中popstate事件在页面加载时触发,但在Firefox或IE10中没有。问题是,我只想监听用户点击后退或前进按钮的popstate事件(或者历史是通过javascript更改),但不想在页面加载时做任何事情。
12