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,如下:
window.opener = null;
window.open('', '_self');
window.close();
未能通过。
关闭页面的代码写在一个ajax返回的结果中的,如下:
$.ajax({
type: 'post',
url: "url",
success: function (data) {
if (data.isOut) {
window.opener = null;
window.open('', '_self');
window.close();
}
else {
alert(data.msg);
}
},
error: function (err) {
alert("异常:" + err);
}
})
解决办法:
window.location.href="about:blank";
window.close();
成功关闭。
Scripts may close only the windows that were opened by it的更多相关文章
- 脚本不得关闭非脚本打开的窗口。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控制无法关闭当前页面
非window.open形式打开的子页面用js的window.close在chrome下就会提示scripts may close only the windows that were opened ...
- js 关闭页面(Scripts may close only the windows that were opened by it.)
传送http://blog.csdn.net/kuangfengbuyi/article/details/52052301 js关闭当前页面,当该页面不是其他页面打开的,而是直接输入url, 直接用w ...
- js关闭浏览器的tab页(兼容)
由于在脚本中使用了 window.close(), 当前非弹出窗口在最新版本的chrome和firefox里总是不能关闭,而在 IE中是可以关闭的 . 在console中弹出提示"Scrip ...
- 【温故而知新-Javascript】窗口效果 (全屏显示窗口、定时关闭窗口)
1.全屏显示窗口 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...
- chrome浏览器关闭标签页面
chrome浏览器关闭标签页提示:Scripts may close only the windows that were opened by it. 解决办法:通过open方法进行关闭. open( ...
- 【经验】JavaScript
1.function closeWin(){ window.open('','_self'); window.opener=null; // window. ...
- chrome JS关闭当前页无效问题
如果没有父窗口,JS中 window.opener = null; window.open("", "_self"); window.close(); 对chr ...
- 谷歌浏览器禁止window.close的问题
当一个窗口不是通过window.open或者window.showModalDialog打开的时候,调用JS的window.close() 谷歌浏览器会提示如下警告,并拒绝执行 Scripts may ...
随机推荐
- oppor9手机怎么录制屏幕视频
我们已经进入互联网时代,每个人都寸步不离手机.电脑等电子产品,看到美丽好看的视频总想记录下来,毕竟看到喜欢的视频还真不太容易,所以问题来了,oppor9手机怎么录制屏幕视频呢?安卓手机上怎么录制屏幕视 ...
- net core webApi返回值
1 多个参数采用结构的形式,如class xyz 2 返回值使用IActionResult 控制,不能使用httpRequestMessage类型 3 url为路由名称+Controller前缀 如下 ...
- C# 利用ReportViewer生成报表
本文主要是利用微软自带的控件ReportViewer进行报表设计的小例子,仅供学习分享使用,如有不足之处,还请指正. 涉及知识点: ReportViewer :位于Microsoft.Reportin ...
- Android项目实战(三十三):AS下获取获取依赖三方的jar文件、aar 转 jar
使用 Android studio 开发项目中,有几种引用三方代码的方式:jar 包 ,类库 ,gradle.build 的compile依赖. 大家会发现github上不少的项目只提供compile ...
- Android为TV端助力 post带数据请求方式,传递的数据格式包括json和map
如下: public static String httpPost(String url, String json) { try { URL u = new URL(url); HttpURLConn ...
- python特性--property
在定义一个类的时候,有时我们需要获取一个类的属性值,而这个属性值需要经过类中的其他属性运算来获得的.那么很容易,只要我们在类中定义一个方法,并且通过调用方法可以获取到那个需要运算的属性值.那么,问题来 ...
- 翻译:MySQL "Got an Error Reading Communication Packet" Errors
前言: 本文是对Muhammad Irfan的这篇博客MySQL "Got an Error Reading Communication Packet" Errors的翻译,如有翻 ...
- 通过Socket让远程电脑执行脚本
实现功能: 客户端发送命令,服务器接收命令并执行 服务端: import socketserver, os class MyTCPHandler(socketserver.BaseRequestHan ...
- IPerf——网络测试工具介绍与源码解析(4)
上篇随笔讲到了TCP模式下的客户端,接下来会讲一下TCP模式普通场景下的服务端,说普通场景则是暂时不考虑双向测试的可能,毕竟了解一项东西还是先从简单的情况下入手会快些. 对于服务端,并不是我们认为的直 ...
- 数据挖掘---Pandas的学习
Pandas介绍(panel + data + analysis) 为什么使用Pandas 便捷的数据处理能力 读取文件方便 封装了Matplotlib.Nu ...