• 检测关闭浏览器和屏蔽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 不行 :(

  • 相关阅读:
    POJ3246
    .NetCore Docker一次记录
    asp.net利用SmtpClient发送邮件
    Assert类的静态方法
    ado.net 连接数据库
    虚拟目录
    web.config配置详细说明
    图片上传
    .NET操作Excel
    asp.net 数据绑定 -- 时间格式
  • 原文地址:https://www.cnblogs.com/whoknows/p/2243299.html
Copyright © 2020-2023  润新知