cocoqi

今天脚本了里写了一句话:

window.close()

但是浏览器却报了警告提示:Scripts may close only the windows that were opened by it,而且也没有能够关闭我想关闭的页面,怎么办呢?找万能的度娘,搜到的解决方案有:

(1) 

  window.open(\'\',\'_self\',\'\');

  window.close();

(2)

  open(location, \'_self\').close();

这两种我都试过了,还是一样有警告信息,并且无法关闭窗口。
最后一种方案是:

  window.location.href="about:blank";
  window.close();

终于成功关闭窗口啦!

分类:

技术点:

相关文章:

  • 2021-10-27
  • 2022-12-23
  • 2021-06-23
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2021-10-07
猜你喜欢
  • 2021-11-27
  • 2021-11-27
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案