Click to See Complete Forum and Search --> : History- the page before
sianni
11-06-2003, 02:50 PM
Here's my situation: The user can get to page C from either page A or page B. If the user comes from page A, I need the title to say "From page A". If the user comes from page B, I need the title to say "From page B". Is it possible to do a check in JavaScript of what the previous page is and then depending on the page, swap the title image? I've tried some samples using history.previous but nothing seems to work. I don't want to have to duplicate the page for just a simple title change. Thanks
AdamGundry
11-06-2003, 03:09 PM
IIRC, security restrictions prevent JS from accessing the URL of the previous page. You can do this with a server-side script such as PHP or ASP, however.
Adam
sianni
11-06-2003, 03:12 PM
I thought that might be the case. Thanks Adam.
alexiworld
05-18-2004, 03:05 PM
AdamGundry,
You can do this with a server-side script such as PHP or ASP, however.
How it can be done?! I am quite sure that browser will send his history to any web server. But If I am wrong please let me know, because I need to catch the previous page too!
Thank you in advance,
Alexi
AdamGundry
05-19-2004, 11:39 AM
Most browsers will send a HTTP header called HTTP_REFERER which contains the URL of the previous page. You should bear in mind that it's not bulletproof, as some do not set it and others may allow it to be changed.
In PHP, you can do something like this:
<? echo $_SERVER['HTTP_REFERER']; ?>
Or SSI:
<!--echo var="HTTP_REFERER"-->
Or ASP (I think...I'm not that good on ASP):
<%=request.servervariables("http_referer")%>
Equivalents should be available for most other server-side languages.
Adam