Does someone know how to have the equivalent of相當於<a href="test" target="_blank"> in the php header() function
<a href="test" target="_blank">
in the php header() function
I need to re direct my php page in new tab.
Does someone know how to have the equivalent of相當於<a href="test" target="_blank"> in the php header() function
<a href="test" target="_blank">
in the php header() function
I need to re direct my php page in new tab.
你不行。 PHP無法控制瀏覽器。
你能做的最好的是:
echo '<script type="text/javascript">window.open(...);</script>';
但是,這可能會彈出窗口攔截器被阻塞。
或者,如果可能的話,您可以擁有任何發起的PHP請求本身設置爲target="_blank"
。
PHP is a server-side language and cannot be used to perform client-side actions, i.e. you cannot open a new window using a header()
重定向。它將始終重定向當前頁面。如果你想在新標籤中打開鏈接,你將不得不使用JavaScript。
例如:
<?php
echo "<script>window.open('http://www.example.com');</script>";
?>
不過,這並不保證工作,因爲用戶可能已經安裝在他們的瀏覽器彈出窗口攔截器。
HTTP重定向不會與客戶端窗口交互。這隻能從HTML命令。 – mario
這不可能與標題。改用JS重定向。 –
[新選項卡中的標題位置]的可能重複(http://stackoverflow.com/questions/12539011/header-location-in-new-tab) –