<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script type="text/javascript"> window.addEventListener("pageshow",function(){ //alert("pageshow"); }); window.addEventListener("pagehide",function(){ //alert("pagehide"); }); window.addEventListener("beforeunload",function(){ //alert("beforeunload"); }); window.addEventListener("blur",function(){ //alert("blur"); }); window.addEventListener("load",function(){ //alert("load"); }); /* readyState 属性返回当前文档的状态(载入中……)。 该属性返回以下值: uninitialized - 还未开始载入 loading - 载入中 interactive - 已加载,文档与用户可以开始交互 complete - 载入完成 */ document.addEventListener('readystatechange',function(){ //alert('document ' + document.readyState); if(document.readyState=="uninitialized"){console.log("uninitialized")} if(document.readyState=="loading"){console.log("loading")} if(document.readyState=="interactive"){console.log("interactive")} if(document.readyState=="complete"){console.log("complete")} }) </script> </head> <body> </body> </html>