如何关闭浏览器选项卡

Shu*_*ham 1 javascript jquery

我无法使用javascript关闭当前的浏览器选项卡.

我试过了-

    window.close(); //1

    window.open("", '_self');//2
    setTimeout(function(){
        window.close();
    },100);

    window.open('','_parent',''); //3
    window.close();

    window.top.opener=null; //4
    window.close();
Run Code Online (Sandbox Code Playgroud)

在chrome中没有什么对我有用

小智 9

window.close方法只允许为脚本使用window.open方法打开的窗口调用.

  • 那就是我试图在第二种方法中做的事情。我正在用javascript打开它,然后关闭它。 (2认同)

Mad*_*mah 5

window.open('', '_self', '').close();
Run Code Online (Sandbox Code Playgroud)

请参阅我在此线程上的原始答案