View Full Version : Go to a specific page if a condition is not met

08-26-2007, 05:47 PM
I would like to put coding in some of my pages so that depending on the previous page the visitor came from, he is send to a specific page.

I mean:
in page B.htm
if the previous page is not page A.htm got to page A.htm
else show page B.htm

ie. The only way to visit page B.htm is when you came from page A.htm

Anybody who can help me?

Philip M
08-26-2007, 06:15 PM
<script type = "text/javascript">
if (document.referrer.indexOf("http://www.yourURL.com") == -1) {
location.href = "http://www.yourURL.com/pageA.html";

08-26-2007, 10:35 PM
Philip M,
This was exactly what I was looking for.

08-26-2007, 11:40 PM
After testing:
Works fine with firefox
Microsoft Internet explorer sends you to page A.htm even when you come from page A.htm
Anybody any ideas

08-27-2007, 12:18 AM
Try this on page B:
if (document.referrer.indexOf('pageA') == -1) {

08-27-2007, 03:21 PM
Thanks Rwedge,
but this coding has the same effect.
It looks like a bug? in the Internet Explorers Javascript interpreter:
The refering page (Page A)(to which I don't want to go back if I come from there) generates the destination page (page B) by a piece of javascript coding:
Then after arriving at page B, document.referrer is empty.
even if I put a complete "url" after top.location= ;
in short:
document.referrer does not contain an address using Internet Explorer (coming from a page where top.location was the destination) while using Firefox it contains the correct url.

Any further ideas are very welcome.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum