heade(location) in a new window
Moderator: General Moderators
heade(location) in a new window
Hi I am using the header(location:) fnction to redirect to a new page, is there a way I can get this page to load into a new browser rather than the original one.
I'm not sure whether it is possible using header but what about other options such as <META HTTP-EQUIV="refresh">??
thanks in advance
alex
I'm not sure whether it is possible using header but what about other options such as <META HTTP-EQUIV="refresh">??
thanks in advance
alex
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
If you learn about HTTP headers (Nothing to do with HTML itself) then you maybe see why it won't work.
The headers are sent before the content which the browser deals with.
header('Location: ....'); just sends a Location: ... header in the HTTP response and thus forces the browser to GET the content from somewhere else
The headers are sent before the content which the browser deals with.
header('Location: ....'); just sends a Location: ... header in the HTTP response and thus forces the browser to GET the content from somewhere else
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
What happens when javascript isn't enabled?br5dy wrote:by the way, why ever use a header funciton to redirect when you could use javascript with much less pain?
How is:
Code: Select all
header("location:http://example.com");Code: Select all
echo ("<script>
window.location='http://example.com';
</script>");Also a header redirect is more likely to redirect faster then a javascript redirect, especially if you're outputting a lot of html before the javascript.
Also javascript redirects are associated with 'doorways' and 'surfer traps' and could be red flagged by Google, where a header is just more "acceptable" by SE's, especially since a header is commonly used when renaming files (instead of a 404 many webmasters will leave the old file up and simply redirect it to the new page)
The javascript method is considered more spammy because when hitting the back button the user often gets fowarded, causing the spam site to receive a few extra page views before the user finally decides to manually type in the url he's trying to go back to (or hit the back button super super fast like 5 times)
Reason enough?