0

I'm the one who started JavaScript yesterday. I made code like this.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
    </head>
    <body>
        <script>
            alert('Hello world \nNice to meet you \n');
        </script>
    </body>
</html>

However, after the code was finished, it was inconvenient to only leave blank pages. Is there a function in JavaScript that kills the running browser tab?

I use Windows as the operating system and Chrome as the browser.

======== 'Window.close();' in the last line of code I added it, but nothing happened.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
    </head>
    <body>
        <script>
            alert('Hello world \nNice to meet you \n');
            window.close();
        </script>
    </body>
</html>
Oh2010
  • 21
  • 5

1 Answers1

0

window.close() will close the current tab.

Refer this stackoverflow question to get an idea why window.close() doesn't work for you. And I also suggest you to clear the cache and sessions and try again.