Javascript to close IE6, IE7, IE8 and Firefox without confirmation?

Suppose I want to have a link or button that, when the user clicks on it, the browser closes without any confirmation dialog box.

He will need to work with Internet Explorer 6, 7, 8 and Firefox.

+3
source share
3 answers

I did some research and found that it is not possible to close a window / tab in Firefox if this window / tab does not open through javascript or if the tab has history pages> 1 (i.e. the back button, since you browse the web pages).

Firefox: . . . , , .

Internet Explorer 6, 7, 8.

: http://www.quirksmode.org/js/detect.html, IE.

if ((userBrowser.browser == "Explorer" && (userBrowser.version == "8" || userBrowser.version == "7"))) {
        window.open('', '_self', '');
        window.close();
    } else if ((userBrowser.browser == "Explorer" && userBrowser.version == "6")) {
        window.opener = null;
        window.close();
    } else {
        window.opener = '';
        window.close(); // attempt to close window first, show user warning message if fails
        alert("To avoid data corruption/loss. Please close this window immedietly.");
    }

, , . , , - . . - , .

, .

+13

. .

, . , , . .

+1

, , . , , , .

:

  • - ( ). - , .
  • - , - , .

, , . , , .

+1

Source: https://habr.com/ru/post/1721167/


All Articles