开发者

Confirm browser back button else stay on page

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 开发者_StackOverflow中文版and instead of Cancel it should say Stay. Thanks


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:

window.onbeforeunload = function() {
  return "Are you sure you wish to leave this delightful page?";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜