javascript - 报错: scripts may close only the windows that were opened by it
迷茫
迷茫 2017-04-10 16:35:41
0
1
924

chrome浏览器关闭不了当前窗口,老是报如题的错

关闭当前窗口方法如下:
function closeWindow(){

         if (navigator.userAgent.indexOf("MSIE") > 0) {
              if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
                   window.opener = null;
                   window.close();
              } else {
                   window.open('', '_top');
                   window.top.close();
              }
         }else if (navigator.userAgent.indexOf("Firefox") > 0) {
              window.location.href = 'about:blank ';
         } else {
              window.opener = null;
              window.open('', '_self', '');
              window.close();
         }
        }
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
黄舟

open(location, '_self').close();
试试这个方法,我这边是可以的

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template