非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控制无法关闭当前页面的更多相关文章

  1. 脚本不得关闭非脚本打开的窗口。Scripts may close only the windows that were opened by it

    今天脚本了里写了一句话: window.close() 但是浏览器却报了警告提示:Scripts may close only the windows that were opened by it,而 ...

  2. Scripts may close only the windows that were opened by it

    关闭当前窗体报以下js错误: Scripts may close only the windows that were opened by it (脚本只能关闭由它打开的窗口) 使用场景,在js中关闭 ...

  3. js 关闭页面(Scripts may close only the windows that were opened by it.)

    传送http://blog.csdn.net/kuangfengbuyi/article/details/52052301 js关闭当前页面,当该页面不是其他页面打开的,而是直接输入url, 直接用w ...

  4. Windows Phone 8初学者开发—第19部分:设置RecordAudio.xaml页面

    原文 Windows Phone 8初学者开发—第19部分:设置RecordAudio.xaml页面 原文地址:  http://channel9.msdn.com/Series/Windows-Ph ...

  5. Windows -- 从注册表删除IE浏览器加载项

    Windows -- 从注册表删除IE浏览器加载项 1.  一部分加载项从注册表以下位置直接删除 2.  一部分扩展项从注册表以下位置直接删除

  6. 在系统启动时,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 ...

  7. Windows 10 Build 14997中Edge浏览器已默认阻止Flash运行

    在上周末偷跑的 Windows 10 Build 14997 向我们传递了很多信息,新增了蓝光过滤器等功能,并有望装备在即将到来的 Creators Update 中.经过深入发掘,外媒发现新版系统中 ...

  8. Windows下的UDP爆了10054--远程主机强迫关闭了一个现有的连接

    原文地址:http://www.cnblogs.com/pasoraku/p/5612105.html 故事是这样的. 前几天在网上逛,看到了一个漂亮的坦克模型. 我觉得这个坦克可以做一个游戏,那需要 ...

  9. win7 提升windows服务权限使非管理员用户可以控制windows服务的开启和关闭

    #include <windows.h>#include <tchar.h>#include <strsafe.h>#include <aclapi.h> ...

随机推荐

  1. Axure中怎么制作锚点

    实现目标 点击导航条不同的菜单,页面跳到菜单相应的位置,实现页面自动滚动. 1.  拖入编辑区3个矩形,并相应命名为菜单1,菜单2 ,菜单3: 2.  再新建3个想要制作的文本框准备进行锚点滚动: 3 ...

  2. redis宕机如何解决?如果是项目上线的宕机呢?

    我们先来了解一下  bridge网络模式 他会创建一个docker0桥,看完这个我们就会知道redis哨兵机制的端口了. 之后继续研究redis宕机的解决办法! 宕机: 服务器停止服务 如果只有一台r ...

  3. asyncio系列之sleep()实现

    先来看个例子,自己实现的模拟耗时操作 例1 import types import select import time import socket import functools class Fu ...

  4. Codeforces 730A:Toda 2(multiset模拟)

    http://codeforces.com/problemset/problem/730/A 题意:有n个人打天梯,想让这n个人的分数相同,每场比赛必须有2-5个人参赛,参赛的人会降低一分,问一个合理 ...

  5. NEST 6.X升级到7.X

    升级比对可访问 NEST 6.X升级到7.X 查看 ElasticClient-CreateIndex 升级前代码,NEST版本6.6.0 ICreateIndexResponse response ...

  6. 开源:C# 代码自动生成工具,支持站点前后台

    前言 写这个项目有很长一段时间了,期间也修修改改,写到最后,自己也没咋用(研究方向变化了). 正文 具体项目开源了:https://github.com/supperlitt/WebAutoCodeO ...

  7. APM系统SkyWalking介绍

    公司最近在构建服务化平台,需要上线APM系统,本篇文章简单的介绍SkyWalking APM APM全称Application Performance Management应用性能管理,目的是通过各种 ...

  8. 使用flink Table &Sql api来构建批量和流式应用(1)Table的基本概念

    从flink的官方文档,我们知道flink的编程模型分为四层,sql层是最高层的api,Table api是中间层,DataStream/DataSet Api 是核心,stateful Stream ...

  9. shell_umask用法

    我曾经用touch命令创建一个文件script,默认的权限是"rw-r- -r- -",有的朋友就有可能问为什么是这种组合?其实,这正是umask命令捣的鬼.在linux上输入:u ...

  10. Vue状态管理之Bus

    一般在项目中,状态管理都是使用Vue官方提供的Vuex 当在多组件之间共享状态变得复杂时,使用Vuex,此外也可以使用Bus来进行简单的状态管理 1.1 父组件与子组件之间的通信 vue.config ...