0

FAIL:

  • chrome window/tab does not get closed

Code:

<script>
function callKiller() {
  window.close();
  self.close();
  parent.close();

  setTimeout(function() { 
    try { 
      window.close(); 
      self.close(); 
      parent.close()
    }catch(e) {
      console.log(e, 'idiot browsers, why you cant kill it you idiot'); 
    } 
  }, 10000);
}
</script>

<!--

  Plugin:

    - Detect iOS?, Android !Chrome
    - Safari?
    - IE or IE EDGE??? 

  Then close the window, Cause no service cant be offered                          
-->
<body onLoad=callKiller(); >
  Sorry, we cant offer you any service. 
    Safari do not have WebRTC and they wont have it anytime sooner. 
    IE Edge do not have WebRTC. Its ORTC not WebRTC. 
    Read the Wiki
    iOS we have no time, for you to write everything in Objective-C, go learn yourself Objective-C

Web_Designer
  • 72,308
  • 93
  • 206
  • 262
  • Possible duplicate of [Close Current Tab](http://stackoverflow.com/questions/14373625/close-current-tab) – Jared Smith Apr 15 '17 at 23:49
  • 1
    As the answer to the dupe states, this isn't actually possible to do reliably, unless the tab was opened programmatically. – Jared Smith Apr 15 '17 at 23:50
  • Can we not use `Confirm(); ?` then it is user who response on it? –  Apr 15 '17 at 23:57
  • 1
    No, because typically when you get the confirm before close its because you as the user have tried to close the tab. There just isn't a way to close the window, I suggest writing a blurb that asks the user to close the window (much like banks do after you log out). – Jared Smith Apr 16 '17 at 00:02
  • Excellent. that will help my issue thank you for the advise. –  Apr 16 '17 at 00:09

1 Answers1

0

This is a security feature installed into chrome a long time ago.

In order for the window.close() function to be used:

The close() method on Window objects should, if all the following conditions are met, close the browsing context A:

  • The corresponding browsing context A is script-closable.

  • The browsing context of the incumbent script is familiar with the browsing context A

  • The browsing context of the incumbent script is allowed to navigate the browsing context A.

A browsing context is script-closable if it is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), or if it is a browsing context whose session history contains only one Document.

So you essentially cannot use javascript to close a window that wasn't opened by the javascript within the page.

Read more here.

My suggestion would be to redirect your visitors to another page.

Saeed Ludeen
  • 368
  • 3
  • 11