Click to See Complete Forum and Search --> : Redirection depending on last page or using the BACK button


bossong
06-02-2003, 08:43 AM
I'm having some difficulty getting some javascript to work and I'm wondering if it's possible at this point. Here's my scenario:

I have 3 web pages I'll refer to as A, B, and C. I start on page A where there's a link to page B. All page B does is redirect you to page C (I don't want to get into details but I need page B). If the user hits the BACK button from page C, I want them to be returned to page A. Please note that page A could be a number of pages but page B and page C will always be the same.

Since I know the URL of page C, I'm trying to determine a match within my script on page B but have had no success. I've tried several things, usually revolving around document.referrer. I'm finding out that document.referrer for page B will always give me page A - even after hitting the BACK button on page C.

Bottom line: Page B needs to determine where you came from so it can redirect you to the proper page. I need this to work in IE6 and Netscape 6+.

Any assistance would be greatly appreciated.

Bill

Khalid Ali
06-02-2003, 08:54 AM
Well here is a suggestion.I am pretty darn sure it will work....:)


in the page B redirect to C using the following syntax

window.location.replace = "Page_C_URL"

Now regardless of which was page A when you click on back button,it should take you to page A which ever it would be..

bossong
06-02-2003, 10:32 AM
Thanks Khalib!

Khalid Ali
06-02-2003, 10:34 AM
Originally posted by bossong
Thanks Khalib!

???

How about "Khalid"

:D

Oh BTW you are welcome..:p

bossong
06-02-2003, 10:40 AM
Sorry about that Khalid.

bossong
06-02-2003, 12:00 PM
Khalid,

Weird thing happened...I tested this code locally and it worked fine for IE 6 and Netscape 6+. However, when I pushed it to our server, it did not function properly for IE 6 (no redirection - a blank page B is displayed). Netscape functioned properly. This was the case on 2 different servers. Any ideas?

Bill

Khalid Ali
06-02-2003, 12:23 PM
It did work on NS in both cases..right...it should cus thats what I know it works for.

For IE ..hunmm..good question..I have to see why IE is f***ing up history because it should not..

can you post the link to one of those pages where it does not work in IE

scriptkid
06-02-2003, 12:28 PM
could pass page a's url in the querystring, a hidden form element, or history.go(-1) or however u use taht history redirection crap

Khalid Ali
06-02-2003, 12:34 PM
Originally posted by scriptkid
could pass page a's url in the querystring, a hidden form element, or history.go(-1) or however u use taht history redirection crap

Yes you can try that ..only in this threads case you will have to do it
history.go(-2) to go back to Page A from C

And if this works for you then in page B you do not need to use
window.location.replace,,instead you can use

window.location.href = urlof page C