javascript - JS : Redirecting with 'window.location' not saving history in Firefox

标签 javascript firefox redirect

我试图在不丢失 Firefox 历史记录的情况下进行重定向。 我用了下没有成功:

window.location = "http://example.com";
window.location.href = "http://example.com";
window.location.assign("http://example.com");

还尝试使用“文档”而不是“窗口”。

我被重定向了,但是浏览器没有添加(或删除)历史记录

任何想法!?

注意:我没有直接调用这个函数,我是在向服务器成功发出 jQuery Ajax 请求后调用它:

$.ajax({
  type: "POST",
  ...
  success: function (data) {},
});

变量数据包含JS重定向函数(window.location.href = "http://example.com")

最佳答案

您可以查看这篇关于 URL 设计的文章:http://warpspire.com/posts/url-design/特别是标题为“Everything should have a url”的部分。基本上你会想要使用 history.pushState 函数将新的 url 添加到浏览器历史记录中。您也可以查看类似的 stackoverflow 帖子:Update URL on AJAX call?Change the URL in the browser without loading the new page using JavaScript

关于javascript - JS : Redirecting with 'window.location' not saving history in Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5018698/

相关文章:

javascript - 如何将多个回调附加到 YouTube API 事件

javascript - 如何检查哪个引导模式已打开

javascript - 当视频位于叠加 block 上时,Youtube嵌入iframe api playVideo()无法在Firefox中运行

internet-explorer - Fiddler 未捕获来自 Firefox 的 Web 请求

firefox - 关闭 Firefox 13 中的内置 RSS 阅读器

python - python如何捕获302重定向url

javascript - 返回到在 Express 中进行重定向调用的文件

javascript - 在 setTimeout 中重定向到当前范围之外的变量中保存的位置

javascript - Texture2D 到 byte[] 到 String

c# - 重定向错误 401.2 未授权