• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

How to catch browser back button event

I need to catch browser back button event. Actually I need that whenever user click the back button of browser the result must be got from the server i.e ASP script should also run. Is it possible?

Waiting for your reply.

Thanks
AQ
0
aqk139
Asked:
aqk139
1 Solution
 
tittlejosephCommented:
I too searched for it many times, but never got this, and frankly speaking there are no event/method meant for it. But yeah you can track if someone is trying to change the page and then stop him for doing so
e.g.

<body onunload="return checkpage()">

function checkpage()
{
 if (confirm('you are trying to surf outside this page\nsure?'))
 return true;

return false;
}

//Warning: Above function will also get execute even if you submit the page.

The other way is expire the ASP page immediately so that whenever it is accessed clicking on back button it is refreshed from web server.

for this use <meta tag> search syntax on web
or use expire property of asp.
0
 
aqk139Author Commented:
Using expire property of ASP does not work. What is the proper place of using this property. I mean at the begining of page or end of page. I tried both but failed.
0
 
tittlejosephCommented:
Try this, should work

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="1981">
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tittlejosephCommented:
try above meta tag on head part of the page
0
 
MoondancerCommented:
Has this helped?
Moondancer - EE Moderator
0
 
Saqib KhanSenior DeveloperCommented:
if you want the Code, to Get Rid of Sessions(Logout Page).then I have the Code, Lemme know if you need it for ASP Sessions.
0
 
MoondancerCommented:
Please return to this question to update and finalize it.

If Asker does not respond, EXPERTS please guide me with closing recommendations.

Thanks,
Moondancer - EE Moderator
0
 
GaryCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept Answer by tittlejoseph
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now