要在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>热门推荐
10 妈妈的祝福语简短优美
11 给新生的简短祝福语
12 生日祝福语 简短独特情话
13 婚礼红包祝福语简短霸气
14 中秋祝福语简短女朋友
15 班务总结祝福语大全简短
16 事业祝福语简短网名
17 生日贺卡祝福语简短创意
18 文案生日祝福语高级简短