Windows 10 reached EOS (end of support) on October 14, 2025. If you are on Windows 10, see this article.

Avatar for Username

Шукати в статтях підтримки

Остерігайтеся нападів зловмисників. Mozilla ніколи не просить вас зателефонувати, надіслати номер телефону у повідомленні або поділитися з кимось особистими даними. Будь ласка, повідомте про підозрілі дії за допомогою меню “Повідомити про зловживання”

Докладніше
Ця тема перенесена в архів. Якщо вам потрібна допомога, запитайте.
Архівовано

How to close a tab using javascript? window.close() doesnt work here.

harshitgor

I am using the following function to close current tab.

function closeWindow() {
           window.open("", "_self");
           window.close(); 
       }
I am using the following function to close current tab. function closeWindow() { window.open("", "_self"); window.close(); }

Усі відповіді (1)

You can only close windows that way that are opened via window.open()

This method is only allowed to be called for windows that were opened by a script using the window.open() method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.