zoukankan      html  css  js  c++  java
  • 关于关闭弹出窗口

    新弹出才能关闭

    function windowclose() {
            var browserName = navigator.appName;
            if (browserName=="Netscape") {
                window.open('', '_self', '');
                window.close();
            }
            else {
                if (browserName == "Microsoft Internet Explorer"){
                    window.opener = "whocares";
                    window.opener = null;
                    window.open('', '_top');
                    window.close();
                }
            }
        }

    火狐和谷歌 需要弹出新窗口才能关闭

    http://blog.csdn.net/aerchi/article/details/41441429

    function closeWindows() {
             var browserName = navigator.appName;
             var browserVer = parseInt(navigator.appVersion);
             //alert(browserName + " : "+browserVer);
    
             //document.getElementById("flashContent").innerHTML = "<br>&nbsp;<font face='Arial' color='blue' size='2'><b> You have been logged out of the Game. Please Close Your Browser Window.</b></font>";
    
             if(browserName == "Microsoft Internet Explorer"){
                 var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;  
                 if (ie7)
                 {  
                   //This method is required to close a window without any prompt for IE7 & greater versions.
                   window.open('','_parent','');
                   window.close();
                 }
                else
                 {
                   //This method is required to close a window without any prompt for IE6
                   this.focus();
                   self.opener = this;
                   self.close();
                 }
            }else{  
                //For NON-IE Browsers except Firefox which doesnt support Auto Close
                try{
                    this.focus();
                    self.opener = this;
                    self.close();
                }
                catch(e){
    
                }
    
                try{
                    window.open('','_self','');
                    window.close();
                }
                catch(e){
    
                }
            }
        }
    <script type="text/javascript">
    function closeWP() {
     var Browser = navigator.appName;
     var indexB = Browser.indexOf('Explorer');
    
     if (indexB > 0) {
        var indexV = navigator.userAgent.indexOf('MSIE') + 5;
        var Version = navigator.userAgent.substring(indexV, indexV + 1);
    
        if (Version >= 7) {
            window.open('', '_self', '');
            window.close();
        }
        else if (Version == 6) {
            window.opener = null;
            window.close();
        }
        else {
            window.opener = '';
            window.close();
        }
    
     }
    else {
        window.close();
     }
    }
    </script>
     $("#closess").click(function(event) {
                if (navigator.userAgent.indexOf("MSIE") > 0) {
                        if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
                            window.opener = null;
                            window.close();
                        } else {
                            window.open('', '_top');
                            window.top.close();
                        }
                    }
                    else if (navigator.userAgent.indexOf("Firefox") > 0) {
                        window.location.href = 'about:blank ';
                    } else {
                        window.opener = null;
                        window.open('', '_self', '');
                        window.close();
                    }
                
            });
        }
    <!-- saved from url=(0059)https://browserstrangeness.bitbucket.io/window_to_close.htm -->
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <title>Window Close Method</title>
    
    <script language="javascript">
    
    function quitBox(cmd)
    {   
        if (cmd=='quit')
        {
            open(location, '_self').close();
        }   
        return false;   
    }
    
    </script>
    
    </head>
    
    <body>
    
    <input type="button" value="Close This Window/Tab" onclick="return quitBox('quit');">
    
    <br><br>
    
    Tested and working in Chrome 34-42, Safari 7-8, Internet Explorer 11 and Firefox 27-40
    
    <br><br>
    
    This window is not the complete code, but the second part only. This is the page that is opened by the working script.
    
    <br><br>
    
    To make this work, go to the opener page here: <a href="http://browserstrangeness.bitbucket.org/window_close_tester.htm">http://browserstrangeness.bitbucket.org/window_close_tester.htm</a>
    
    
    
    </body></html>
  • 相关阅读:
    Django-website 程序案例系列-3 URL详解
    Django-website 程序案例系列-1 最简单的web服务器
    c# 多维数组、交错数组(转化为DataTable)
    c++(重载等号=操作为深拷贝)
    c# 导入c++ dll
    Nhibernate HQL 匿名类(严格说是map的使用以及构造函数的使用
    spring.net 集成nhibernate配置文件(这里暴露了GetCurrentSession 对于 CurrentSession unbond thread这里给出了解决方法)
    hibernate mapping文件中 xmlns会导致linq to xml 查询不到对应的节点
    linq to xml
    xml 操作(动态添加 property属性 其他节点同理)
  • 原文地址:https://www.cnblogs.com/hupan508/p/6881447.html
Copyright © 2011-2022 走看看