簡體   English   中英

window.opener.location.href 歷史記錄不適用於 firefox

[英]window.opener.location.href history not working on firefox

我正在使用 window.open 打開一個 window,並且在該 window 中有某些鏈接,點擊鏈接后它會將原始頁面重定向到點擊的鏈接並關閉新的 window。

$('a').on('click',function(e){
  e.preventDefault();
  var get_href=$(this).attr('href');

  window.opener.location.href=get_href;
  window.close();
});

現在,當我點擊 chrome 中的后退按鈕時,重定向將我們帶到預訂頁面,它會將它帶回帳戶頁面,但是當我在 firefox 上嘗試時,它會將頁面重定向到登錄頁面,而不是它應該重定向到帳戶頁面.if 我們可以重新加載頁面也可以。

我試過了

window.onbeforeunload = function(){window.location.reload();}

這在 php header

// 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
});

window.onbeforeunload = function(){window.location.reload();}永遠不會工作。 那是拒絕服務攻擊

假設來自同一來源的頁面,你可以試試這個

  1. 在父母:

window.name="parentWindow"

  1. 在孩子

<a href="page.html" target="parentWindow">Open page in parent</a>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM