0

I need to create a script that closes the current tab, this tab is opened with an url and not with javascript. I've tested all the methods I can find but none works, I always get the same error :

"Scripts may close only the windows that were opened by it.".

How can I achieve this?

Erch
  • 571
  • 6
  • 24
Spialdor
  • 1,215
  • 4
  • 15
  • 36
  • Just use this code: close(); – xoxo Sep 25 '18 at 10:19
  • Duplicate of https://stackoverflow.com/questions/19761241/window-close-and-self-close-do-not-close-the-window-in-chrome – Ms.Tamil Sep 25 '18 at 10:21
  • Same error @KamalaHB – Spialdor Sep 25 '18 at 10:21
  • 1
    @Ms.Tamil this post is from 2013, most of solutions doesn't works now – Spialdor Sep 25 '18 at 10:22
  • The key takeaway from that answer is and remains: *"This means, with one small exception, __javascript must not be allowed to close a window that was not opened by that same javascript.__"* – deceze Sep 25 '18 at 10:24
  • So I can't close this tab ? Is there maybe a way in Php ? – Spialdor Sep 25 '18 at 10:28
  • PHP has no concept of "tabs" or "windows". No, you cannot futz with a user's browser windows unless you have opened that window programmatically in the first place. – deceze Sep 25 '18 at 10:28
  • But if I open it programmatically the one which open it can't be closed by javascript, so there will still be one tab always open ? – Spialdor Sep 25 '18 at 10:34
  • Yes. Which is pretty much the point of this restriction: don't futz with the user's open windows. – deceze Sep 25 '18 at 10:37

0 Answers0