Solved

PHP Header redirection

Posted on 2003-12-11
3
784 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 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