Chrome“脚本可能只会关闭由它打开的窗口”错误 [英] Chrome “Scripts may close only the windows that were opened by it” error

查看:508
本文介绍了Chrome“脚本可能只会关闭由它打开的窗口”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

window.close();//false

window.open(location, '_self', '');
window.close();//false

open(location, '_self').close();//false

Chrome 45.0.2454.85 m,Firefox也有问题。

Chrome 45.0.2454.85 m, Firefox also has the problem.

请帮忙...

控制台选项截图

推荐答案

您应该将打开的窗口存储在变量中。

You should store your opened window in a variable.

var popup = window.open(location, '_blank', '');
popup.close();

编辑:因为你在同一个屏幕上打开一个新页面,在_self中打开不起作用想像我编辑的那样做_blank。

Opening in _self does not work since you open a new page in the same screen, you might want to do _blank like i've edited.

这篇关于Chrome“脚本可能只会关闭由它打开的窗口”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆