AngularJS window.close不起作用

AngularJS window.close not working

本文关键字:不起作用 close window AngularJS      更新时间:2023-09-26

我在调用 window.close 函数时遇到问题,但没有收到以下错误:

脚本只能关闭由它打开的窗口。

以下是我如何布置我的应用程序:

.HTML:

<html ng-app="mynewAPP" ng-controller="appCTRL">
....blahblah </html>

我的 Angular 控件工作正常,但是当我调用window.close时,它不起作用(至少关闭部分......应用程序的其余部分很好(。

app.controller("appCTRL" ,function( [injections]){
  $window.close();
}

我将如何允许AngularJS关闭它所在的窗口?

例如,下面的脚本可以正常工作:(基本JS(

<html>
<head>
<script type="text/javascript">
    function closeme(){
        window.close(); 
    }
    </script></head>
    <body onload="closeme()"></body>
</html>

对于那些想知道我如何打开页面的人,只需访问浏览器上的"mypage.html"。没什么好看的。

由于安全限制,您只能关闭带有由 javascript 打开的window.close的窗口。

参考: MDN