传送http://blog.csdn.net/kuangfengbuyi/article/details/52052301

js关闭当前页面,当该页面不是其他页面打开的,而是直接输入url,

直接用window.close()无法关闭。

以下代码可以实现不同浏览器的关闭操作:

    function closewin(){
if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") !=-1) {
window.location.href="about:blank";
window.close();
} else {
window.opener = null;
window.open("", "_self");
window.close();
}
}

location对象

function currLocation()
{
alert(window.location)
}
function newLocation()
{
window.location="/index.html"
}

js 关闭页面(Scripts may close only the windows that were opened by it.)的更多相关文章

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

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

  2. 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 ...

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

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

  4. JS关闭页面弹窗提醒

    <html> <head><title>JS测试</title> <script type="text/javascript" ...

  5. JS关闭窗口或JS关闭页面的几种代码

    //JS定时自动关闭窗口 <script language="javascript"> <!-- function closewin(){ self.opener ...

  6. JS关闭窗口或JS关闭页面的几种代码!

    第一种:JS定时自动关闭窗口 <script language="javascript"> <!-- function closewin(){ self.open ...

  7. JS 关闭 页面 浏览器 事件

    JS监听关闭浏览器事件关键字: js监听关闭浏览器事件Onunload与OnbeforeunloadOnunload,onbeforeunload都是在刷新或关闭时调用,可以在<script&g ...

  8. JS 关闭页面事件

    主页面调用:<script src="<%=ResolveUrl("../JS/QuitJS.js") %>" type="text ...

  9. [小问题笔记(一)] js关闭页面window.close() 无效,不弹提示直接关闭

    window.close(); 单独写这句,各个浏览器效果都不一样.比如IE(不是所有版本)会弹提示: 点确定之后才会关闭.而有些浏览器压根就没反应. 需要让它不弹提示,直接关闭,在window.cl ...

随机推荐

  1. css选择器的分类及优先级计算方法总结

    首先声明一下CSS三大特性—— 继承. 优先级和层叠.继承即子类元素继承父类的样式;优先级是指不同类别样式的权重比较;层叠是说当数量相同时,通过层叠(后者覆盖前者)的样式. css选择符分类 首先来看 ...

  2. Shell基本正则表达式和扩展正则表达式

    BRE和ERE的区别 基本正则表达式(BRE)和扩展正则表达式(ERE)的区别仅仅是元字符(meta charactor)的区别而已. BRE: 只有^$.*[]是元字符 ERE: ^$.[]*+() ...

  3. (52) C# 串口通讯

    一.串口通讯基本参数 1.波特率:每秒传输n个多少个二进制位. 例如 9600 b/s  = 1200 B/s=  1.172KB/S 2.传输数据格式 数据格式由起始位(start bit).数据位 ...

  4. vue富文本vue-quill-editor

    这个富文本需要装一下插件 "quill": "^1.3.6" "quill-image-drop-module": "^1.0.3 ...

  5. 学习 Doug Lea 大神写的——Scalable IO in Java

    学习 Doug Lea 大神写的--Scalable IO in Java 网络服务 Web services.分布式对象等等都具有相同的处理结构 Read request Decode reques ...

  6. vue computed 源码分析

    我们来看看computed的实现.最简单的一个demo如下: <html> <head> <meta http-equiv="Content-Type" ...

  7. 看了Google编码规范,我突然有个感觉

    那么个编码规范,充分体现了西方人的自我感觉良好,以及以自己为中心的程度, 以及西方人对待事物的双重标准.

  8. C语言static和局部变量

    #include <stdio.h> void test(); int main() { /************************************************ ...

  9. D3.js 动画 过渡效果 (V3版本)

    一 . 过渡的启动   启动过渡效果,与以下四个方法相关:   d3.transition([selection],[name]) //创建一个过渡对象.但是由于每个选择集中都有transition( ...

  10. C#编程入门--MYSQLHELPER

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...