Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmin the "back" button in IE

Status
Not open for further replies.

PavanKumarU

Programmer
Jan 31, 2003
56
0
0
US
Hi,
we had a requirement recently, and i have been researching for a solution, in vain. Hope osmeone could throw some light.
We ahve created a browser based application that renders crystal reports to users. The last page in a sequence of parameter prompting, criteria validating is the showreport.asp page. The server side coding is done in asp and we are using Session objects to store report data. Once the report is rendered to the browser, user might leave the browser in 3 ways. Actually closing the browser, hitting a button thta we provide, or hitting the browser's back button. We are ok with the first two, but when user clicks the back button i want an event to fire in which i would like to include code that would destroy the session and redirect the user to the index page, where he/she has the option selecting a report.
Could someone throw light on how to capture the hitting of the back button and how to code it?
any help is much appreciated.
Thanks
 
Hi,
Thanks for a fast reply. Really appreciate it.
But could you tell me in what event shld i call all these javascript snippets? I am confused because, i dont know what "button event" i shld write this code in.
Please help.
Thanks
Pavan
 
actually, i am seeing the first one. but in general, this is what i want to do.
If user clicks the "back" button, then goto a particular page, clean up session variables, and move to the index page.
Alternatively, i could, check if the location the browser is trying to move to is the "previous" page and then redirect it to the cleanup page and so on.
Please enlighten
Thanks
Pavan
 
This is just off the top of my head -- I've never tested it so I don't know if it will work, but it might be worth a try.

I'll name a couple of pages so that my explanation is clear.

showreport.asp is the page with the final report
PageD is the page right before showreport.asp
PageC is the page right before PageD
PageA is the first page of the report generation system.

At the top of PageD include expiration code (pragma nocache and so forth). Also at the top of PageD insert some code that checks for the HTTP_REFERER: if the referer isn't PageC then expire the session and redirect the user to PageA.

This should work fine if, when the user presses the back button (or Alt-leftarrow or whatever), the referer is set to either showreport.asp or PageD, or even if it's blank (I say this because I'm not certain what the referer will be set to if the user presses the back button, but I'm pretty sure it won't be set to PageC if PageD is set to expire (and therefore refreshes)).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top