4

I have tried some many codes but none is helping my requirement is to close the tab which is open on button click in a page.

window.open("about:blank", "_self");
window.close();

This piece of code on click function in angular but it showing blank page on current active tab but not closing the window.

it not a anchor it is a button and here its using angular code we need to do this.

Hel_UI
  • 115
  • 1
  • 1
  • 7
  • Possible duplicate of [Close Current Tab](https://stackoverflow.com/questions/14373625/close-current-tab) – Adrita Sharma Sep 17 '19 at 10:27
  • Possible duplicate of [How to close current tab in a browser window?](https://stackoverflow.com/questions/2076299/how-to-close-current-tab-in-a-browser-window) – Ricardo Rocha Sep 17 '19 at 10:28
  • If JavaScript did not open it, you do not have the ability to close it. I doubt any of the hacks work. – epascarello Sep 17 '19 at 11:47
  • @epascarello actually the above two lines pasted is a hack but that hack showing a blank page and not closing the tab is there are any other use hack do you know – Hel_UI Sep 17 '19 at 13:51
  • The links people said are dupes have all the hacks. Problem is things that worked years ago were patched by browsers..... – epascarello Sep 17 '19 at 14:24
  • @epascarello how to make it work for the latest browsers can please help me out. – Hel_UI Sep 18 '19 at 07:51
  • In the angular>=6, it is not allow to close tab and it gives me `Scripts may close only the windows that were opened by them.` warning. @Hel_UI – Margi212 Jul 14 '21 at 05:29

0 Answers0