卸載(或刷新)頁(yè)面時(shí)觸發(fā)卸載事件。您可以嘗試運(yùn)行以下代碼來(lái)了解如何在 JavaScript 中實(shí)現(xiàn) onunload?事件。
示例
<!DOCTYPE html> <html> <body onunload="newFunc()"> <p>Close the page and see what happens!</p> <p>This event may give unexpected results.</p> <script> function newFunc() { alert("Thank you!"); } </script> </body> </html>
登錄后復(fù)制
以上就是在JavaScript中,"onunload"事件的用途是什么?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!