JavaScript 中 onbeforeunload 事件有什么用?
如果要在文档加载之前触发事件,可以使用onbeforeunload事件。
示例
你可以尝试运行以下代码来学习如何在 JavaScript 中实现 onbeforeunload 事件。
<!DOCTYPE html>
<html>
<body onbeforeunload="return myFunction()">
<a href="https://www.qries.com">Click to open Qries</a>
<script>
function myFunction() {
return "Working with onbeforeunload event";
}
</script>
</body>
</html>
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP