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> ...
随机推荐
- rbash限制用户执行的命令
rbash限制用户执行的命令 软连接 sudo ln -s /bin/bash /bin/rbash sudo bash -c 'echo "/bin/rbash" >> ...
- Vue的生命周期函数
详解Vue Lifecycle 先来看看vue官网对vue生命周期的介绍 Vue实例有一个完整的生命周期,也就是从开始创建.初始化数据.编译模板.挂载Dom.渲染→更新→渲染.销毁等一系列过程,我们称 ...
- Jrebel激活服务搭建
前言 因为平时的开发工具是使用IntelliJ IDEA,所以热部署项目代码的时候,使用的Jrebel.因为Jrebel是收费的,所以以前用的时候都是在网上找破解方法(国人通用做法),在网上找到的办法 ...
- Codeforces 755C:PolandBall and Forest(并查集)
http://codeforces.com/problemset/problem/755/C 题意:该图是类似于树,给出n个点,接下来p[i]表示在树上离 i 距离最远的 id 是p[i],如果距离相 ...
- 我的那些年(12)~公司技术转行,我也跟着转到java了
回到目录 我的那些年(12)~公司技术转行,我也跟着转到java了 CTO换人了 微软技术栈不被认可经常被喷 技术统一向java转 换了mac book后,docker还是很占内存 学习springb ...
- mybatis的插入与批量插入的返回ID的原理
目录 背景 底层调用方法 单个对象插入 列表批量插入 完成 背景 最近正在整理之前基于mybatis的半ORM框架.原本的框架底层类ORM操作是通过StringBuilder的append拼接的,这次 ...
- scrapy基础知识之随机切换fake-useragent 库的使用:
pip install fake-useragent from fake_useragent import UserAgent ua = UserAgent() middlewares.py from ...
- Spring Cloud Alibaba | 序言
目录 Spring Cloud Alibaba | 序言 1. Spring Cloud Alibaba是什么? 2. 主要功能 3. 组件 4. 版本说明 4.1 版本依赖关系 4.2 组件版本关系 ...
- C语言学习书籍推荐《C语言入门经典(第4版)》
霍顿 (Ivor Horton) (作者), 杨浩 (译者) <C语言入门经典(第4版)>的目标是使你在C语言程序设计方面由一位初学者成为一位称职的程序员.读者基本不需要具备任何编程知识, ...
- css3系列之弹性盒子 flex
弹性盒子(伸缩盒) 注意,本篇会很长,非常长, 因为弹性盒子的知识点比较多 搜索 弹性盒子的属性 ctrl + F 如果觉得图太小, ctrl + +键 设置弹性盒子的属性: display:f ...