当前位置: 代码迷 >> 综合 >> 小米6手机如何虚拟定位
  详细解决方案

小米6手机如何虚拟定位

热度:87   发布时间:2023-09-08 08:02:07.0
小米6手机如何虚拟定位
<body>标签只有onload\onunload\onbeforeunload事件,而没有onclose事件。不管页面是关闭还是刷新都会执行onunload事件。如何捕捉到页面关闭呢? 

    页面加载时只执行onload

    页面关闭时只执行onunload

    页面刷新时先执行onbeforeunload,然后onunload,最后onload。这样我们可以在onbeforeunload中加一个标记,在onunload中判断该标记,即可达到判断页面是否真的关闭了。

<html>
 <head>
  <title>判断页面是关闭还是刷新</title>
 </head>

 <body onunload="fclose();" onload="fload();" onbeforeunload="bfunload();">
  <script language="javascript">
  var s = "test";
  function fclose()
  {
     if(s=="no")
        alert(?unload me!=?+s+?这是刷新页面!?);
     else
        alert(?这是关闭页面?);
  }

  function fload()
  {
     alert("load me!="+s);
  }

  function bfunload()
  {
     s = "no";
  }
  </script>
 </body>
</html> 小米6手机如何虚拟定位
  相关解决方案