Solved

PHP Header redirection

Posted on 2003-12-11
3
775 Views
Last Modified: 2011-10-03
When using either of the following headers, can you make it open in a new window? (i.e. target=_blank)?????

header('Location: http://www.example.com');

or

header('Refresh: 5; url=http://www.example.com');


Probably very easy, just can't put my finger on it,

Thanks!
0
Comment
Question by:Wiired
3 Comments
 
LVL 13

Accepted Solution

by:
lozloz earned 50 total points
ID: 9925058
nope not to my knowledge, you'll need to use some javascript to do that. and i don't think your 2nd header syntax is correct - that looks like a javascript-esque string in a php function to me

first page:

<?
// your code
header("Location: example.php");
exit;
?>

example.php:

<html>
<head>
<script language="JavaScript">
<!--
function open_window(theURL,winName,features) {
  var a=window.open(theURL,winName,features);
  a.focus();
}
//-->
</script>
</head>
<body onLoad="open_window('http://www.example.com','example','scrollbars=yes,width=720,height=550,resizable=yes');">
<?
// your second page goes here
?>
</body>
</html>

hope that helps

loz
0
 
LVL 1

Expert Comment

by:Rayni
ID: 9925599
You could aslo try

<head>
  <META HTTP-EQUIV="Refresh" CONTENT="3; TARGET=_blank; URL=http://www.some.org/some.html">
</head>

- Daniel
0
 
LVL 6

Expert Comment

by:DoppyNL
ID: 9927258
you can't do it with headers or with a refresh.
You will have to use some sort of client side scripting like javascript.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now