关闭窗口时如何显示警报消息?

编程入门 行业动态 更新时间:2024-10-28 08:22:43
本文介绍了关闭窗口时如何显示警报消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复: 如何防止关闭浏览器窗口?

Possible Duplicate: How to prevent closing browser window?

我想显示一个带有注销按钮的警告消息请在关闭窗口之前注销",当用户尝试关闭窗口并且单击注销按钮后,可以关闭窗口.如何实现呢?

I want to show an alert message "Please logout before closing the window" with an logout button, when an user tries to close the window and after clicking on logout button the window can be closed. How to achieve this?

推荐答案

可以尝试的另一种实现方式:

Another implementation you can try:

<html> <head> <script type="text/javascript"> window.onbeforeunload = function() { return "Did you save your stuff?" } </script> </head> <body> </body> </html>

更多推荐

关闭窗口时如何显示警报消息?

本文发布于:2023-11-27 16:48:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   关闭窗口   消息

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!