That would close the window you opened. Modern browsers locked down closing of windows. If you do not create the window/tab, you are most likely not going to be be closing it.
– epascarelloNov 21 '22 at 01:49
See [`Window.close()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/close). What exactly are your expectations? What's not working? See [ask].
– jsejcksnNov 21 '22 at 02:14
i want to close the current tab but when i use window.close() the browser says ` Scripts may close only the windows that were opened by them `. I tried searching on google and tried everything but still got the error
– TungntNov 21 '22 at 02:38
[^](https://stackoverflow.com/questions/74513427/how-to-close-browsers-current-tab-using-javascript#comment131534834_74513427) @NhấtTiếuNạiHà Instead of opening a new window and closing the current one, just [reuse the current one](https://stackoverflow.com/a/1226718/438273).
– jsejcksnNov 21 '22 at 03:03
@jsejcksn I mean I don't need to open a new tab, just close the current tab
– TungntNov 21 '22 at 03:29