• 关闭浏览器弹出对话框事件onbeforeunload http://www.blogjava.net/jennyli/articles/82351.html


    在点击浏览器关闭按钮关闭浏览器的时候,有时不希望它直接关闭,希望弹出对话框提示客户,这个时候就需要用到事件onbeforeunload,用法如下:
    <script language="javascript">
    <!--
    function opCheckUnload(){
      if(g_blnCheckUnload){
        try{
          window.event.returnValue = "if close the window,the auto task will complete with document no update version";
        }catch(e){}
      }
    }
    -->
    </script>

    <body onbeforeunload="opCheckUnload();">
    </body>

    不过这种用法不支持firefox,因为firefox不支持window.event,所以本人改了一种方式,应用如下:
    window.onbeforeunload = function() {
       if(g_blnCheckUnload){
         return("if close the window,the auto task will complete with document no update version!");
       }
    }

    这样几种浏览器都支持了,弹出对话框如下:


    但这里有个问题,本来还没有解决的,我用的浏览器是中文版,但我做的系统是英文版,这个事件弹出来的窗口所显示的语言随浏览器,没有办法自己在javascript里设置。
  • 相关阅读:
    scgi_params
    ngin 模块及模板
    nginx常用模块
    HTML
    nginx部署网页小游戏
    nginx的server标签还有日志管理
    关于使用yum安装的nginx的主从配置文件的碎碎念
    判断所ping主机的操作系统
    CentOS 7修改主机名
    CentOS7 设置系统时间
  • 原文地址:https://www.cnblogs.com/si812cn/p/1407587.html
Copyright © 2020-2023  润新知