关于弹出窗口
Posted hupan508
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于弹出窗口相关的知识,希望对你有一定的参考价值。
火狐和谷歌 需要弹出新窗口才能关闭
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="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>
以上是关于关于弹出窗口的主要内容,如果未能解决你的问题,请参考以下文章