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

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?

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

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

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.

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

This works for me

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

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

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

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