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

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();

终于成功关闭窗口啦!

相关文章:

  • 2022-12-23
  • 2022-02-27
  • 2021-12-05
  • 2021-06-13
  • 2022-12-23
  • 2021-06-24
  • 2021-07-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-01-20
  • 2021-07-06
  • 2021-11-27
相关资源
相似解决方案