Target="_blank" in header() php function

Does someone know how to have the equivalent of <a href=“” target=“_blank”> in the php header() function ?
i think it may be possible because the info of _blank is passed in the header of the page, but i’ve looked in the http 1.1 specs and found nothing yet !
thx very much

That’s not how the header() function works. If you want to open a new window, you’ll have to send some javascript that calls “window.open()”.

eg


if(condition){
  // open new window
  echo "<script language=\\"javascript\\">window.open(\\"http://www.example.com\\",\\"_blank\\");</script>";
}
// the rest of your page here.

actually it’s a question that’s been asked to me !!! i’ll try to explain it :wink:
it’s for a mambo based site
when i click on a link in the menu, i’d like to make the page open in a new window if i’m logged in, else open a login/pass form in the same window
i’m not sure i’m clear … sorry
the thing is i’d like to avoid java to make the code portable !!!

Hmm. I don’t think you can do what you want to with header(). I can understand that you don’t want to use Javascript, but there is no other way that I can see.

Off Topic:

Why does the content need to open in a new window anyway? Speaking for myself, I hate windows that open themselves without me asking them to. If I do want a new window, I can right click.


  <?php
  echo '<a href="whatever"';
  if ($auth->loggedni()) echo ' target="_BLANK"';
  echo '>Whatever</a>';
  ?>
  

Yes? No?

Chilijam -> maybe i’ve found a way but i haven’t tested it yet … it’s there :

Window-target
Specifies the named window of the current page; can be used to stop a page appearing in a frame with many (not all) browsers. E.g.
<META HTTP-EQUIV=“Window-target” CONTENT=“_top”>
or (HTTP header)
Window-target: _top
… so maybe by replacing _top by _blank ???

someonewhois -> as i said it’s a question to help someone else so i dunno if it’s helpfull or not, i’ll tell him

… but thx anyway both of you :wink: