Open xinglie opened 8 years ago
Magix第1个版本做了hash与pushState之间的切换兼容 关于url解析可以看这篇
当时在做history.pushState时(2012年),发现对于onpopstate对于不同的浏览器是不一样的。
$(window).on("popstate", function() { alert('popstate'); });
上述代码在chrome中页面加载完成时竟然会弹出 popstate。 现在仍然能够搜出很多在stackoverflow问这个问题的人,如 http://stackoverflow.com/questions/4688164/window-bind-popstate http://stackoverflow.com/questions/6421769/popstate-on-pages-load-in-chrome/
popstate
当时阅读了pjax,使用了类似如下的解决方案
var initialURL = location.href,popped $(window).bind('popstate', function(event) { var initialPop = !popped && location.href == initialURL popped = true if ( initialPop ) return
当然,现在并没有这样的问题了
Magix第1个版本做了hash与pushState之间的切换兼容 关于url解析可以看这篇
当时在做history.pushState时(2012年),发现对于onpopstate对于不同的浏览器是不一样的。
上述代码在chrome中页面加载完成时竟然会弹出
popstate
。 现在仍然能够搜出很多在stackoverflow问这个问题的人,如 http://stackoverflow.com/questions/4688164/window-bind-popstate http://stackoverflow.com/questions/6421769/popstate-on-pages-load-in-chrome/当时阅读了pjax,使用了类似如下的解决方案
当然,现在并没有这样的问题了