Help - Search - Members - Calendar
Full Version: javascript automatic go back
Forums > Resource Center > Webmasters' Corner > Resolved Topics
phoenixpyre
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
just get a redirect code and set it back to the homepage
mipadi
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
dang... i got it to work before i read this XD

thanks though
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.