为了账号安全,请及时绑定邮箱和手机立即绑定

window.opener.close()无效

window.opener.close()无效

婷婷同学_ 2018-11-13 13:21:38
1.父页面window.open()打开新页面var targetWeb=null;if(targetWeb){     targetWeb.focus(); }else{     targetWeb=window.open('https://segmentfault.com','segmentfault'); }2.子页面中关闭父页面window.opener.close();发现子页面无法关闭父页面,会提示:Scripts may close only the windows that were opened by it但若换成:window.opener.location.href='https://www.hao123.com' 却可以,请问是什么原因
查看完整描述

1 回答

?
神不在的星期二

TA贡献1963条经验 获得超6个赞

还是在一本书上找到了答案:浏览器的主窗口,在没有得到用户的允许时不能关闭它。弹窗是可以不经过用户的允许关闭自己。


查看完整回答
反对 回复 2018-12-27
  • 1 回答
  • 0 关注
  • 1784 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号