In javascript or jquery I need to add an alert when the user clicks on the browser back button that has an ok/cancel button model, but instead of “Ok” it should say Leave and instead of Cancel it should say Stay. Thanks
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t control the confirmation dialog button text, it’s a hard coded feature of
confirm()and is whatever the browser has…not much you can do about it.For the actual display you can use
window.onbeforeunload, but it won’t be specific to the back button, any action leaving the page will trigger this, for example: