在 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>
廣告