How to get notification when Back button is clicked

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeet232
    New Member
    • Jul 2007
    • 22

    #1

    How to get notification when Back button is clicked

    Hi, how can I get to know when user clicks browser back button? I want my own javascript code to be executed when this happens.

    Also, is there a way that whenever any link in the page is clicked, my code executes. I can't add eventhandler to every link. Can it be done at once?

    Thanks for your time
    Jeet Singh
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You can use onbeforeunload. This will fire before the user leaves the page. Note that it will also fire when reloading, when using the forward button or when closing the browser.

    Comment

    Working...