关闭当前窗体报以下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…
由于在脚本中使用了 window.close(), 当前非弹出窗口在最新版本的chrome和firefox里总是不能关闭,而在 IE中是可以关闭的 . 在console中弹出提示"Scripts may close only the windows that were opened by it" (脚本只能关闭它所打开的窗口),[如下图所示] , 不明白是什么原因. 经过一段时间的折腾.终于明白了问题所在. 首先,什么是非弹出窗口呢? 非弹出窗口,即是指(opener=null 及 非…
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…
当一个窗口不是通过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…