2017-08-03 22 views
0

I'm提交表單在新標籤頁中:如何重定向舊標籤後,我提出一個新的標籤

<form action="xxx.php" target="_blank" method="post"> 

但舊標籤停留在形式和我倒是想發送提交後到另一個頁面。

謝謝!

+0

您還可以使用標頭('位置! url.php'); – HebleV

+0

這個解決方案的另一篇文章,檢查:[(https://stackoverflow.com/questions/8773622/close-window-aft呃重定向](https://stackoverflow.com/questions/8773622/close-window -aft er-redirect) –

+0

不是我所需要的,謝謝 – Logic

回答

0

兩個選項:

1)只需卸下target="_blank"和重定向的形式在同一頁面。

2)使用jQuery執行函數形式提交後:

$('#myForm').submit(function(e) { 
    // similar behavior as an HTTP redirect 
    window.location.replace("http://stackoverflow.com"); 
}); 
+0

謝謝,但是我需要使用POST在另一個頁面打開表格,因爲打算打開一個PDF文件,但我喜歡上一個選項卡轉到另一個頁面 – Logic

+0

我的意思是,我需要它打開到不同的頁面,其中一個在一個新的選項卡 – Logic

+0

然後你可以在你的表單中使用onsubmit =「myFunction()」並在myFunction中重定向頁面。 –

0

製造它..

通過GET

function load(){ 
       <?php 
         $url = "XXX.php?VAR=".$Z; 
         echo "window.open('$url');".PHP_EOL; 
         echo "window.location.href = 'YYY.php';"; 
       ?> 
      } 
+0

好極了!如果我的評論幫助了你,請注意它:) –

相關問題