Log In · Register

 
 
Closed TopicStart new topic
javascript automatic go back, ok or PHP
phoenixpyre
post Feb 6 2007, 08:59 PM
Post #1


Senior Member
*****

Group: Member
Posts: 793
Joined: Jun 2006
Member No: 425,250



i need to know if there is a way to do the following:

>Click a link that goes to a page
>have that page it goes to display a message like "this page isnt here"
>and automatically redirect BACK (as in history BACK) one page??
 
*incoherent*
post Feb 6 2007, 09:23 PM
Post #2





Guest






just get a redirect code and set it back to the homepage
 
*mipadi*
post Feb 7 2007, 12:21 AM
Post #3





Guest






I'm not a JavaScript guru. I do know that the last page in history can be accessed via JavaScript like this:
CODE
history.go(-1)

so if you can find a way to feed that to a redirect in JavaScript, you're set.

You could do it with PHP, too. When clicking a link, this will give you the page that the user came from:
CODE
$_SERVER['HTTP_REFERER']

which you could then feed to header() like so:
CODE
<?php
header('Location: ' . $_SERVER['HTTP_REFERER']);
?>

The problem is that header() does not work if any text (i.e. html coding) has been written to the HTTP stream already. In other words, you can't send part of a webpage and then use header() to redirect.

Maybe this will give you a place to start, though.
 
phoenixpyre
post Feb 7 2007, 09:14 PM
Post #4


Senior Member
*****

Group: Member
Posts: 793
Joined: Jun 2006
Member No: 425,250



dang... i got it to work before i read this XD

thanks though
 

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: