【发布时间】:2021-01-29 10:01:15
【问题描述】:
我正在使用 window.open 打开一个窗口,在该窗口中单击链接时会出现某些链接,它将原始页面重定向到单击的链接并关闭新窗口。
$('a').on('click',function(e){
e.preventDefault();
var get_href=$(this).attr('href');
window.opener.location.href=get_href;
window.close();
});
现在,当我单击 chrome 中的后退按钮时,重定向会将我们带到预订页面,它会将其带回帐户页面,但是当我在 firefox 上尝试时,它会将页面重定向到登录页面,而不是它应该重定向到帐户页面。如果我们可以重新加载页面也可以。
我试过了
window.onbeforeunload = function(){window.location.reload();}
这在 php 头文件中
// any valid date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified right now
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: private, no-store, max-age=0, no-cache, must-revalidate, post- check=0, pre-check=0");
// HTTP/1.0
header("Pragma: no-cache");
但是没有一个在工作下面的代码正在工作它正在引发警报但没有重新加载
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = "\o/";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome
});
【问题讨论】:
标签: javascript firefox browser-history back