JavaScript/ jquery for Closing Browser FireFox / chrome / IE

前端 未结 5 1469
后悔当初
后悔当初 2021-01-21 10:26

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

As I have try with window.close()

But it only work for IE.

相关标签:
5条回答
  • 2021-01-21 11:05

    Can check Browser and write respective script for IE / FireFox

    IE---->

    window.close()
    

    FireFox --->

    var answer = confirm("Do you want to close this window ?");
     if (answer){
    
    netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
        window.close();
     }
     else{
         stop;
     }
    
    0 讨论(0)
  • 2021-01-21 11:13

    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)

    0 讨论(0)
  • 2021-01-21 11:16

    Try this snippet

    window.close()
    
    0 讨论(0)
  • 2021-01-21 11:17

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

    0 讨论(0)
  • 2021-01-21 11:28

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

    <script type="text/javascript">
        function CloseThis() {
                 var win = window.open('', '_self');
                 window.close();
                 win.close(); return false;
        }
    </script>
    
    0 讨论(0)
提交回复
热议问题