首页 > 代码库 > 关于弹出窗口
关于弹出窗口
火狐和谷歌 需要弹出新窗口才能关闭
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> <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=http://www.mamicode.com/"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://www.mamicode.com/"http://browserstrangeness.bitbucket.org/window_close_tester.htm">http://browserstrangeness.bitbucket.org/window_close_tester.htm</a> </body></html>
关于弹出窗口
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。