scripts may close only the windows that were opened by it 浏览器JS控制无法关闭当前页面
非window.open形式打开的子页面用js的window.close在chrome下就会提示scripts may close only the windows that were opened by it。
网上的很多解决方法都是把当前页面为空,在IE和360浏览器也不能直接关闭页面,翻到stack overflow的解决方案:
if(navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") != -1) {
open(location, '_self').close();
window.location.href="about:blank";
window.close();
}else {
window.opener = null;
window.open("", "_self");
window.close();
open(location, '_self').close();
}
open(location, '_self').close(); 加了这个非火狐和chrome(像360浏览器之类)就能直接把当前页面关闭了。
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() 但是浏览器却报了警告提示:Scripts may close only the windows that were opened by it,而 ...
- Scripts may close only the windows that were opened by it
关闭当前窗体报以下js错误: Scripts may close only the windows that were opened by it (脚本只能关闭由它打开的窗口) 使用场景,在js中关闭 ...
- js 关闭页面(Scripts may close only the windows that were opened by it.)
传送http://blog.csdn.net/kuangfengbuyi/article/details/52052301 js关闭当前页面,当该页面不是其他页面打开的,而是直接输入url, 直接用w ...
- Windows Phone 8初学者开发—第19部分:设置RecordAudio.xaml页面
原文 Windows Phone 8初学者开发—第19部分:设置RecordAudio.xaml页面 原文地址: http://channel9.msdn.com/Series/Windows-Ph ...
- Windows -- 从注册表删除IE浏览器加载项
Windows -- 从注册表删除IE浏览器加载项 1. 一部分加载项从注册表以下位置直接删除 2. 一部分扩展项从注册表以下位置直接删除
- 在系统启动时,Windows Vista 中、 在 Windows 7 中,Windows Server 2008 中和在 Windows Server 2008 R2 中的 497 天后未关闭 TIME_WAIT 状态的所有 TCP/IP 端口
在系统启动时,Windows Vista 中. 在 Windows 7 中,Windows Server 2008 中和在 Windows Server 2008 R2 中的 497 天后未关闭 TI ...
- Windows 10 Build 14997中Edge浏览器已默认阻止Flash运行
在上周末偷跑的 Windows 10 Build 14997 向我们传递了很多信息,新增了蓝光过滤器等功能,并有望装备在即将到来的 Creators Update 中.经过深入发掘,外媒发现新版系统中 ...
- Windows下的UDP爆了10054--远程主机强迫关闭了一个现有的连接
原文地址:http://www.cnblogs.com/pasoraku/p/5612105.html 故事是这样的. 前几天在网上逛,看到了一个漂亮的坦克模型. 我觉得这个坦克可以做一个游戏,那需要 ...
- win7 提升windows服务权限使非管理员用户可以控制windows服务的开启和关闭
#include <windows.h>#include <tchar.h>#include <strsafe.h>#include <aclapi.h> ...
随机推荐
- Ubuntu18.04安装postgresql-10
Ubuntu18安装postgresql-10 最近切换Ubuntu作为办公系统,所有软件安装都要重来一遍. 官方文档: https://www.postgresql.org/download/lin ...
- 并发编程-concurrent指南-阻塞双端队列BlockingDeque
java.util.concurrent 包里的 BlockingDeque 接口表示一个线程安放入和提取实例的双端队列. BlockingDeque 类是一个双端队列,在不能够插入元素时,它将阻塞住 ...
- git中常用的操作命令有哪些?常用操作命令归纳
git中常用的操作命令有哪些?本篇文章就给到大家归纳了一些git中常用操作命令.有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. git开始 全局配置:配置用户名和e-mail地址 1 ...
- HTTP、HTTPS常用的默认端口号
端口号标识了一个主机上进行通信的不同的应用程序. 1.HTTP协议代理服务器常用端口号:80/8080/3128/8081/9098 2.SOCKS代理协议服务器常用端口号:1080 3.FTP(文件 ...
- STL库的应用
容器分为两类:序列式容器和关联式容器. 序列式容器,其中的元素不一定有序,但都可以被排序.如:vector.list.deque.stack.queue.heap.priority_queue.sli ...
- 西门子S7-1200与 G120系列变频器USS通信
西门子S7-1200 紧凑型PLC在当前的市场中有着广泛的应用,作为经常与SINAMICS G120系列变频器共同使用的PLC,其USS通信协议的使用一直在市场上有着非常广泛的应用.本文将主要介绍如何 ...
- Oracle数据库常用的脚本命令(一)
--连接数据库的命令connect,用于切换连接用户,简写形式conn--语法格式:conn 用户名/密码conn yanln/yanln --显示当前登录的用户show user --执行操作系统的 ...
- VM虚拟机 VMWare Workstation Pro v15.0.1 中文破解版
虚拟机软件VMware Workstation Pro 15.0 全新版本发布,此次更新了诸多客户机操作系统版本,另外完全兼容Win10创意者更新支持.12.0之后属于大型更新,专门为Win10的安装 ...
- servlet的几个函数
request.getContextPath 上下文,例如 /bignews1 (自带 “ / ”) request.getScheme() 协议,例如HTTP request.getServer ...
- Bzoj: 2073 [POI2004]PRZ 题解
2073: [POI2004]PRZ Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 401 Solved: 296[Submit][Status][D ...