zoukankan      html  css  js  c++  java
  • 检测关闭浏览器和屏蔽F5

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    </head>
    <body>
    检测浏览器关闭,同时屏蔽F5
    listen browser colse event and disable F5,
    </body>
    </html>
    <script type="text/javascript">
    <!--
    window.onbeforeunload
    = onbeforeunload_handler;
    window.onunload
    = onunload_handler;
    document.onkeydown
    = disableF5;
    function onbeforeunload_handler(){
    if(1==1){
    var warning="Close this window?";
    return warning;
    }

    }
    function onunload_handler(){


    }
    function disableF5(e)
    {

    if (!e)
    {
    var e = window.event;
    }
    var keycode = e.keyCode;
    if (e.which)
    keycode
    = e.which;

    var src = e.srcElement;
    if (e.target)
    {
    src
    = e.target;
    }
    // 116 = F5
    if (116== keycode)
    {
    // Firefox and other non IE browsers
    if (e.preventDefault)
    {
    e.preventDefault();
    e.stopPropagation();
    }
    // Internet Explorer
    elseif (e.keyCode)
    {
    e.keyCode
    =0;
    e.returnValue
    =false;
    e.cancelBubble
    =true;
    }

    returnfalse;
    }
    }

    -->
    </script>

    IE6 不行 :(

  • 相关阅读:
    方法的调用机制
    类的成员之二:方法
    类的成员之一:属性
    关键字static
    构造器
    this关键字
    递归方法(recursion)
    方法重载(二)
    GTID 跳过脚本
    mydumper 找不到libmysqlclient.so.20
  • 原文地址:https://www.cnblogs.com/whoknows/p/2243299.html
Copyright © 2011-2022 走看看