要在HTML中卸载文档时执行脚本?
该onbeforeunload当文档准备好被卸载事件属性”触发。
示例
您可以尝试运行以下代码以实现onbeforeunload属性-
<!DOCTYPE html>
<html>
<body onbeforeunload = "return display()">
<p>Close this window or press F5.</p>
<script>
function display() {
return "Wanna stay here or leave?";
}
</script>
</body>
</html>热门推荐
5 薛之谦祝福语简短
10 同学道别祝福语简短
11 猪年幽默祝福语简短
12 汤姆猫祝福语简短霸气
13 上司生日祝福语简短 女性
14 毕业祝福语简短给同学
15 五二零朋友祝福语大全简短
16 新老师祝福语 简短独特
17 祝产妇的祝福语简短
18 新年探亲祝福语简短精辟