Now we need to determine whether the browser is closed or refreshed, and perform the corresponding operation...
Following the voice in heart.
Refresh call:OnunloadClose call:onbeforeunloadCan be specified in the <script> script through window.onunload or specified in <body>
Onunload
onbeforeunload
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> </body> <script> window.onbeforeunload = function(){ return "quit?"; } </script> </html>
Reference: http://www.jianshu.com/p/e920...
load event
load() method
Example:
$("img").load(function(){ $("p").text("Image loaded"); });
Modified question: Here is a question similar to yours, take a look: /q/10...
Refresh call:
Onunload
Close call:
onbeforeunload
Can be specified in the <script> script through window.onunload or specified in <body>
Reference: http://www.jianshu.com/p/e920...
load event
load() method
Example:
Modified question:
Here is a question similar to yours, take a look:
/q/10...