How to trap Back/Fwd buttons of browser?

when i load an ASP page, is it possible to find whether we have come to that page after clicking Back/Forward button? i.e. can i trap these events and take actions based on the event.
I want do take certain actions depending on the
button clicked - if back/forward button is clicked then instead of sending the request to server, i
want to load the page from client and do some checking.
gauravAsked:
Who is Participating?
 
NetminderConnect With a Mentor Commented:
Per recommendation, points refunded and question closed.

Netminder
CS Moderator
0
 
thirdCommented:
it's more convenient to use sessions rather than tracking down these events which as far as i know not possible. e.g. on a login page, create a session say "UserName" (that will be filled with this asp page). in your code check if that session has a valid value else simply display an error.

If Session("UserName") = "" Then
  Response.Write ("<DIV ALIGN=CENTER>You are not logged in!</DIV>")    
  Response.End
End If

...
your asp scripts here....
...

Session("UserName") = ""
0
 
gauravAuthor Commented:
The purpose is from checking the user authentication. I want do take certain actions depending on the button clicked - if back/forward button is clicked then instead of sending the request to server, i want to load the page from client and do some checking.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
webwomanCommented:
Is this limited to forward/back from only certain pages? If so, you could use document.referrer, which would give you the URL they came from.

You're not going to load the page from the CLIENT -- you can't force that. If you want to store some values on the client, use cookies and check for them.

This is pretty common for a passworded site. They log in, a cookie gets stored, you check for those cookie values on each subsequent page. Usually you put name/date and maybe pw in the cookie, and check them.
0
 
gauravAuthor Commented:
no - its not for certain documents but for all the pages - also, since lots of data in form of XML DOM is sent to the client, its not possible to use cookies also. If the back / forwar button is clicked, i want to check if that xml dom exists in client, if yes then reload the page from the client side only else send the request to server.
0
 
Nitin SontakkeDeveloperCommented:
Dear Gaurav,

A real comment only. No solution to your answer.

With my current knowledge of http, i think you are expecting a bit too much. HTTP is stateless and both client and server just forget everything about each other after a single set of data transfer (request/response).

And essentially for this reason all the business about, session state, cookies, etc.

I hope you get my point. Any doubts/questions?

0
 
Nitin SontakkeDeveloperCommented:
I wanted to say "No solution to your question."
0
 
MoondancerCommented:
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.
____________________________________________

----------------------->>>>>>>>>>>>>>    Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.  Please let me know if no response the next 3 days.

NEW topic areas added Feb 8, 2002.  http://www.experts-exchange.com/jsp/zonesAll.jsp

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange
0
 
lexxwernCommented:
________________________________________
do not accept this comment as the answer

this question has been abandoned. experts please
post recommendations below to help the moderators.



________________________________________
my recommendation
0 point paq
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.