仅在清除IE上的浏览器缓存后,window.location.href才能工作 [英] window.location.href works only after clearing browser cache on IE

查看:53
本文介绍了仅在清除IE上的浏览器缓存后,window.location.href才能工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了非常奇怪的问题.

I have stuck with really weird issue.

这是代码示例

$.ajax({
    method: "POST",
    data: content,
    url: '/signin/',
    success: function (response) {
        window.location.href = 'test.html';
    }, 
    error: function (xhr, status, err) {
        errorHandler(xhr);
    }
});

首先,我认为重定向仅在打开调试器后才有效,并朝该方向进行搜索.
根据结果​​和线程,我注释了所有 console.log 语句.没有运气.

First I thought redirection works only after opening debugger, and searched in that direction.
According to results and threads I commented all console.log statements. No luck.

然后发现只有重定向不起作用.
然后我尝试了
window.location.replace("test.html");
window.location.assign("test.html");
window.location.href = test.html
window.open('test.html','_ self',null,false); setTimeout('window.navigate("test.html");',1); 仍然没有运气..

Then found that only redirection is not working.
Then I tried
window.location.replace("test.html");,
window.location.assign("test.html");,
window.location.href = test.html,
window.open('test.html','_self', null , false);, setTimeout('window.navigate("test.html");', 1); still no luck..

现在,我弄清楚了何时打开调试器并清除浏览器的缓存并再次关闭调试器,然后重定向仅在一次之后有效.

Now I figured out when I open debugger and clear browser's cache and close the debugger again, then redirection works only once not after that.

要进行重定向工作,我必须每次都清除浏览器的缓存,或者必须保持调试器处于打开状态.

如何在不打开开发人员工具的情况下进行重定向工作?

我非常感谢您的帮助.

谢谢.

推荐答案

强制重定向不是问题.
还有另一个令人困惑的问题,如此答案<中所述,当开发者工具未打开时,IE正在使用缓存的响应/a>.

Actully redirection was not an issue.
There was another bizzare issue, IE was using cached response when developer tool is not open as explained in this answer.

所以我只是在我的Ajax请求中添加了 cache:false .

So I just had add cache : false to my ajax request.

这篇关于仅在清除IE上的浏览器缓存后,window.location.href才能工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆