关闭当前窗体报以下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", suc…
今天脚本了里写了一句话: window.close() 但是浏览器却报了警告提示:Scripts may close only the windows that were opened by it,而且也没有能够关闭我想关闭的页面,怎么办呢?找万能的度娘,搜到的解决方案有: (1) window.open('','_self',''); window.close(); (2) open(location, '_self').close(); 这两种我都试过了,还是一样有警告信息,并且无法关闭窗口…
非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.index…
传送http://blog.csdn.net/kuangfengbuyi/article/details/52052301 js关闭当前页面,当该页面不是其他页面打开的,而是直接输入url, 直接用window.close()无法关闭. 以下代码可以实现不同浏览器的关闭操作: function closewin(){ if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("…
由于在脚本中使用了 window.close(), 当前非弹出窗口在最新版本的chrome和firefox里总是不能关闭,而在 IE中是可以关闭的 . 在console中弹出提示"Scripts may close only the windows that were opened by it" (脚本只能关闭它所打开的窗口),[如下图所示] , 不明白是什么原因. 经过一段时间的折腾.终于明白了问题所在. 首先,什么是非弹出窗口呢? 非弹出窗口,即是指(opener=null 及 非…
1.全屏显示窗口 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="…
chrome浏览器关闭标签页提示:Scripts may close only the windows that were opened by it. 解决办法:通过open方法进行关闭. open(location, '_self').close();…
1.function closeWin(){             window.open('','_self');       window.opener=null;  //    window.open(location, '_self').close();    window.close();      }这段是兼容最新浏览器的关闭窗口代码,但是在chrome下以输入网址打开的页面无法使用window.close(),会提示Scripts may close only the windo…
如果没有父窗口,JS中 window.opener = null; window.open("", "_self"); window.close(); 对chrome 及Firefox是无效的,那么针对这种情况该怎么办呢. 工具/原料 chrome,Firefox浏览器 方法/步骤 1 JS 关闭网页,之前通过以上方式,可以解决Firefox chrome等浏览器不兼容的问题,但是随着浏览器版本升级,现在无效了.会提示: Scripts may close only…
当一个窗口不是通过window.open或者window.showModalDialog打开的时候,调用JS的window.close() 谷歌浏览器会提示如下警告,并拒绝执行 Scripts may close only the windows that were opened by it. 解决方法:(此方法无效) function closeWindow(){ var browserName=navigator.appName; alert(browserName); if (browse…