Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can we detect browser back button clicked in javascript?
I am using onbeforeunload() function in my page.
But this function calls everytime- on back button click, on refresh

Can we check that back button is clicked?
Posted
Comments
ridoy 22-Aug-12 12:21pm    
yes,you can check whether back button is clicked
Sweetynewb 23-Aug-12 0:38am    
How we can disable it? Can you give me example?
i dont want to call onbeforeunload() function on back button.

1 solution

This is asked at least once a day. The answer is always the same. you can't reliably detect it, and if you try to stop it from happening, your hack can easily be broken by someone who wants it to be. The best thing is to write your site properly so the back button doesn't do anything you don't want it to.
 
Share this answer
 
Comments
ridoy 22-Aug-12 12:20pm    
good answer..+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900