编辑下面的代码:【加编码】
<html> <body onbeforeunload="return myFunction()"> <p>该实例演示了如何向 body 元素添加 "onbeforeunload" 事件。</p> <p>关闭当前窗口,按下 F5 或点击以下链接触发 onbeforeunload 事件。</p> <a href="/">点击调整到ziqiangxuetang.com</a> <script> function myFunction() { return "我在这写点东西..."; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂