window.close()不起作用 - 脚本可能只关闭由它打开的窗口 [英] window.close() doesn't work - Scripts may close only the windows that were opened by it

查看:2546
本文介绍了window.close()不起作用 - 脚本可能只关闭由它打开的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图通过Javascript的 window.close()方法关闭窗口时,我总是遇到问题,而浏览器显示如下控制台上的消息:

I'm having a problem always when I'm trying to close a window through the window.close() method of the Javascript, while the browser displays the below message on the console:

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

这发生在页面的每个部分。我可以直接运行链接,按钮或脚本,但始终显示此消息。

This occurs in every part of the page. I can run this directly of a link, button, or a script, but this message always are displayed.

我试图替换 window.close(); 下面的函数(或其变体)的方法,但没有再发生任何事情:

I'm tried to replace the window.close(); method for the functions (or variants of these) below, but nothing happened again:

window.open('', '_self', '');
window.close();


推荐答案

我搜索了很多网页谷歌和这里的Stack Overflow,但没有任何建议解决了我的问题。

I searched for many pages of the web through of the Google and here on the Stack Overflow, but nothing suggested resolved my problem.

经过多次尝试和踢后,我改变了测试控制器的方式。然后我发现问题一直发生在Chrome浏览器中我通过 Ctrl + Shift + T 快捷方式重新打开页面。所以页面运行了,但没有父窗口引用,因此无法关闭。

After many attempts and "kicks", I changed my way of to test that controller. Then I have discovered that the problem occurs always which I reopened the page through of the Ctrl + Shift + T shortcut in Chrome. So the page ran, but without a parent window reference, and because this can't be closed.

这篇关于window.close()不起作用 - 脚本可能只关闭由它打开的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆