Close browser tab using JavaScript

To close the current tab or browser window in JS, just call the method:

window.close();
JS

At this time, the method works, but soon in browsers due to changes in security policy, this method can only be called on windows that were opened using the window.open() method.

An example of page reloading by clicking on a link or button:

<a href="#" onclick="window.close(); return false;">Close page</a>
HTML
02.03.2021, updated 19.03.2021
2117

Comments

to add a comment.

Other publications

Auto height textarea
Auto-resizing textarea can be done in the following way...
174
0
Item appearing in turn
Examples of how to make elements progressively appear using standard jQuery animation functions.
82
0
How to make blocks of the same height
The easiest way to make blocks with the same height is using jQuery, for example, let's take the following block layout.
64
0