用于关闭浏览器FireFox / chrome / IE的JavaScript / jquery

时间:2021-12-20 23:53:50

AS I need JavaScript / jquery Code for Closing Browser's ( FireFox / Chrome and IE..)

我需要用于关闭浏览器的JavaScript / jquery代码(FireFox / Chrome和IE ..)

As I have try with window.close()

正如我尝试使用window.close()

But it only work for IE.

但它只适用于IE。

Is any other way..?

还有其他方式..?

5 个解决方案

#1


5  

This worked for IE and Chrome. (window.close() worked for IE, then win.close for chrome)

这适用于IE和Chrome。 (window.close()适用于IE,然后win.close适用于chrome)

<script type="text/javascript">
    function CloseThis() {
             var win = window.open('', '_self');
             window.close();
             win.close(); return false;
    }
</script>

#2


3  

Can check Browser and write respective script for IE / FireFox

可以检查浏览器并为IE / FireFox编写相应的脚本

IE---->

IE ---->

window.close()

FireFox --->

FireFox --->

var answer = confirm("Do you want to close this window ?");
 if (answer){

netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
    window.close();
 }
 else{
     stop;
 }

#3


2  

I don't think that is possible as javascript can only interact with the pages rendered by the browser, not the actual browser.

我不认为这是可能的,因为javascript只能与浏览器呈现的页面交互,而不是实际的浏览器。

#4


2  

Windows can only be closed by scripts (window.close()) that were opened by scripts in the first place. So generally, this isn't possible (https://developer.mozilla.org/en/DOM/window.close)

Windows只能由脚本(window.close())关闭,这些脚本首先由脚本打开。所以一般来说,这是不可能的(https://developer.mozilla.org/en/DOM/window.close)

#5


0  

Try this snippet

试试这个片段

window.close()

#1


5  

This worked for IE and Chrome. (window.close() worked for IE, then win.close for chrome)

这适用于IE和Chrome。 (window.close()适用于IE,然后win.close适用于chrome)

<script type="text/javascript">
    function CloseThis() {
             var win = window.open('', '_self');
             window.close();
             win.close(); return false;
    }
</script>

#2


3  

Can check Browser and write respective script for IE / FireFox

可以检查浏览器并为IE / FireFox编写相应的脚本

IE---->

IE ---->

window.close()

FireFox --->

FireFox --->

var answer = confirm("Do you want to close this window ?");
 if (answer){

netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
    window.close();
 }
 else{
     stop;
 }

#3


2  

I don't think that is possible as javascript can only interact with the pages rendered by the browser, not the actual browser.

我不认为这是可能的,因为javascript只能与浏览器呈现的页面交互,而不是实际的浏览器。

#4


2  

Windows can only be closed by scripts (window.close()) that were opened by scripts in the first place. So generally, this isn't possible (https://developer.mozilla.org/en/DOM/window.close)

Windows只能由脚本(window.close())关闭,这些脚本首先由脚本打开。所以一般来说,这是不可能的(https://developer.mozilla.org/en/DOM/window.close)

#5


0  

Try this snippet

试试这个片段

window.close()