PHP标题重定向在新窗口中?

时间:2021-11-16 15:22:34

For a banner management system i use a

对于横幅管理系统,我使用了

 header("Location: http://www.awebsite.com");

to redirect to the proper website. Is it possible to force this header script to open in a new window?

重定向到正确的网站。是否可以强制此标题脚本在新窗口中打开?

5 个解决方案

#1


<a href='yourbannerscript.php' target='_blank'>...</a>

#2


No. If you want a new window, you have to deliver the redirect as HTML/Javascript.

不。如果您想要一个新窗口,您必须以HTML / Javascript的形式提供重定向。

#3


This works for me

这对我有用

echo "<script>window.open('yoursite.com');</script>";

#4


It would be nasty, and might not be want you want, but including an IFRAME tag pointing to a php file with the header redirect could be a solution. Doesn't create a new window, but creates a window-within-a-window.

这将是令人讨厌的,可能不是你想要的,但包括一个指向带有头重定向的php文件的IFRAME标签可能是一个解决方案。不创建新窗口,但会在窗口内创建窗口。

<iframe src="/myredirectscript.php"></iframe>

#5


You should redirect to a page with a redirect metà tag like the one on the most voted answer at Open HTML meta redirect in new window

你应该重定向到一个带有重定向metà标签的页面,就像在新窗口中打开HTML元重定向中投票最多的答案一样

So the page you redirect your headers to will contain a metà tag with:

因此,您将标题重定向到的页面将包含一个metà标记:

<meta http-equiv="refresh" />
<meta content="0; URL=javascript:window.open('http://uri.of
.your.pagewhereyouwabtoredirect/path','_parent');"/>

#1


<a href='yourbannerscript.php' target='_blank'>...</a>

#2


No. If you want a new window, you have to deliver the redirect as HTML/Javascript.

不。如果您想要一个新窗口,您必须以HTML / Javascript的形式提供重定向。

#3


This works for me

这对我有用

echo "<script>window.open('yoursite.com');</script>";

#4


It would be nasty, and might not be want you want, but including an IFRAME tag pointing to a php file with the header redirect could be a solution. Doesn't create a new window, but creates a window-within-a-window.

这将是令人讨厌的,可能不是你想要的,但包括一个指向带有头重定向的php文件的IFRAME标签可能是一个解决方案。不创建新窗口,但会在窗口内创建窗口。

<iframe src="/myredirectscript.php"></iframe>

#5


You should redirect to a page with a redirect metà tag like the one on the most voted answer at Open HTML meta redirect in new window

你应该重定向到一个带有重定向metà标签的页面,就像在新窗口中打开HTML元重定向中投票最多的答案一样

So the page you redirect your headers to will contain a metà tag with:

因此,您将标题重定向到的页面将包含一个metà标记:

<meta http-equiv="refresh" />
<meta content="0; URL=javascript:window.open('http://uri.of
.your.pagewhereyouwabtoredirect/path','_parent');"/>