在 HTML 中关闭浏览器窗口时执行脚本?
htmlweb developmentfront end technology更新于 2025/8/15 22:04:17
unloaded 属性会在您关闭 Web 浏览器窗口时触发。您可以尝试运行以下代码,在 HTML 中实现 unloaded 属性 −
示例
<!DOCTYPE html>
<html>
<body onunload = "display()">
<h2>Tutorialspoint</h2>
<h3>Simply Easy learning</h3>
<script>
function display() {
alert("Bye!");
}
</script>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

