window.close()提示 "Scripts may close only the windows that were opened by it"
来源:互联网 发布:免费加入团队软件 编辑:程序博客网 时间:2024/06/06 05:46
由于在脚本中使用了 window.close(), 当前非弹出窗口在最新版本的chrome和firefox里总是不能关闭,而在 IE中是可以关闭的 。
在console中弹出提示”Scripts may close only the windows that were opened by it”
首先,什么是非弹出窗口呢?
非弹出窗口,即是指(opener=null 及 非window.open()打开的窗口,比如URL直接输入的浏览器窗体, 或由其它程序调用产生的浏览器窗口)。
其次,window.close() 怎么理解呢?
可参考 https://developer.mozilla.org/en-US/docs/Web/API/window.close
在某些实际应用中,window.close() and self.close() 是不能关闭非弹出窗口(opener=null及非window.open()打开的窗口)。
以下代码也只是保证了在ie下不再出现确认对话框, 对chrome和ff不能关闭是没有任何作用的
<script type="text/javascript">function closeWP() { var Browser = navigator.appName; var indexB = Browser.indexOf('Explorer'); if (indexB > 0) { var indexV = navigator.userAgent.indexOf('MSIE') + 5; var Version = navigator.userAgent.substring(indexV, indexV + 1); if (Version >= 7) { window.open('', '_self', ''); window.close(); } else if (Version == 6) { window.opener = null; window.close(); } else { window.opener = ''; window.close(); } }else { window.close(); }}</script>
https://developer.mozilla.org/en-US/docs/Web/API/window.close
https://productforums.google.com/forum/#!topic/chrome/GjsCrvPYGlA
http://stackoverflow.com/questions/19761241/window-close-and-self-close-do-not-close-the-window-in-chrome
最后结论:
在新弹出的标签页中去掉”关闭页面”的按钮, 很多网站包括百度等都规避了window.close()
- window.close()提示 "Scripts may close only the windows that were opened by it"
- [乐意黎原创] window.close()提示 "Scripts may close only the windows that were opened by it"
- js 关闭页面(Scripts may close only the windows that were opened by it.)
- js点击关闭当前浏览器Scripts may close only the windows that were opened by it.
- JS倒计时结束关闭页面:Scripts may close only the windows that were opened by it.
- window.close() doesn't work - Scripts may not close windows that were not opened by script.
- Why is the window.close() works in IE browser but not FireFox? "Warning: Scripts may not close windo
- window.close()不提示
- Application did not close the cursor or database object that was opened here 异常
- window.close取消关闭提示.
- AboutView -- Close the second window
- window.close
- window.close()
- window.close()
- Window.close()
- window.close and self.close do not close the window in Chrome
- 如何让window.close()不提示
- window.close()不提示的解决方法
- ios 地图导航
- jdbc
- android在xml文件中定义drawable数组、id数组等
- 微信分销系统微商城网站
- AndroidMultitool3.5.6 批量打渠道包
- window.close()提示 "Scripts may close only the windows that were opened by it"
- 67. Add Binary
- Object-C NSTimer定时器使用
- GRE填空的注意要点
- 【腾讯bugly干货分享】精神哥手把手教你如何智斗ANR
- 启动eclipse错误:Failed to write core dump
- android-Ultra-Pull-To-Refresh Dem实例 Eclipse中编译的办法
- android平台led开发之硬件抽象层 (二)
- linux rar将文件解压到制定目录