...

View Full Version : Am I the last page in the history?



schworak
01-10-2012, 09:28 PM
I know that Javascript cannot look at the URLs in the browser's history object. I am not concerned with the content.

I have a page that is a serious problem when user's hit the BACK button and get to it because it causes a ping-pong affect of going back, and then loading the next page again (and again and again) each time the user hits back.

Is there any way to know if the page being displayed is not the last page in the history?

If I can see that it is not the last page then I can send the user to the correct page instead of just pushing them forward.

THANKS!

Old Pedant
01-11-2012, 12:10 AM
Why not just set a cookie (with no expiration, so it will just be an in-memory session cookie) on the page with the BACK problem. So then when you do get to the page the BACK goes to, if the cookie is present you know to send them someplace different (after erasing the cookie, on the assumption they might cycle back through again, possibly).

schworak
01-11-2012, 06:34 PM
There are several paths that a user can use to get to that screen with the ping-pong issue so I would need to clear the cookie the first time it loads off the server. Let me play with that idea. It is a good suggestion if I can make it work.

VIPStephan
01-11-2012, 06:48 PM
Cookies are a problem for people that are blocking cookies, though. The actual root of the problem is the page that redirects people without their consent and this is where you should start solving the problem. Isn’t there any other way to achieve what you want?

schworak
01-11-2012, 06:51 PM
AWESOME!

Why didn't I think of that in the first place. So slick and simple. The server generates a unique value when the page loads and tucks it in as a javascript variable. Then when the user hits BACK the code doesn't regenerate at the server level so the script can kick to the correct page.

No more Ping-Pong!

schworak
01-11-2012, 06:52 PM
Cookies are a problem for people that are blocking cookies, though. The actual root of the problem is the page that redirects people without their consent and this is where you should start solving the problem. Isnít there any other way to achieve what you want?

No, not in this case.

And all the users must have cookies enabled or they can't get this far into the application.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum