å½ææ¡£æä¸ä¸ªåèµæºæ£å¨è¢«å¸è½½æ¶ï¼è§¦å unload
äºä»¶ã
Event
äºä»¶å¤çç¨åºå±æ§ï¼Event handler propertyï¼ onunload
å®å¨ä¸é¢ä¸¤ä¸ªäºä»¶å被触åï¼
ææ¡£å¤äºä»¥ä¸ç¶æï¼
window.open
, alert
, confirm
ç.)请注æunload
äºä»¶ä¹éµå¾ªææ¡£æ ï¼ç¶ iframe ä¼å¨å iframe å¸è½½åå¸è½½ (åèä¸é¢çä¾å).
<!doctype html>
<html>
<head>
<title>Parent Frame</title>
<script>
window.addEventListener("beforeunload", function (event) {
console.log("I am the 1st one.");
});
window.addEventListener("unload", function (event) {
console.log("I am the 3rd one.");
});
</script>
</head>
<body>
<iframe src="child-frame.html"></iframe>
</body>
</html>
ä¸é¢æ¯ child-frame.html çå
容
:
<!doctype html>
<html>
<head>
<title>Child Frame</title>
<script>
window.addEventListener("beforeunload", function (event) {
console.log("I am the 2nd one.");
});
window.addEventListener("unload", function (event) {
console.log("I am the 4th and last oneâ¦");
});
</script>
</head>
<body>
â»
</body>
</html>
å½ç¶ iframe 被å¸è½½ï¼äºä»¶å°æ console.log()
æ¶æ¯æè¿°ç顺åºè§¦åã
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4