【发布时间】:2013-05-30 08:08:22
【问题描述】:
我一直在尝试让单页应用程序在 Chrome、Safari 和 Firefox 上运行,但 Firefox 似乎根本没有执行 window.onpopstate。
window.onpopstate = function() {
fullpath = location.pathname;
console.log(fullpath);
}
我有 .htaccess 将所有请求路由回 index.html,所以当客户端发出请求时,浏览器将 url 存储为 javascript 变量并通过 index.html 中的 js 传递它
在 Firefox 中运行时,变量不会传递到 index.html 页面。对于如何深入研究这个问题,任何人都有解决方案或任何建议?
【问题讨论】:
-
什么时候不触发?在页面加载或用户导航时?
-
页面加载。变量永远不会被加载。
-
所以在页面加载时使用当前 url 设置变量
-
这似乎解决了我的问题。谢谢。
标签: javascript html .htaccess html5-history