javascript - 关闭 Angular SPA 中的浏览器窗口

标签 javascript angularjs

我尝试了相当多版本的 window.close() 方法,试图解决“脚本可能无法关闭不是由脚本打开的窗口”的问题。错误并解决了下面的代码。我不再收到脚本错误,但以下所有内容都重定向到我的单页应用程序的索引页面。 大家有什么想法或想法吗?

所以我从这个页面调用它(ng-click)/index.html#/complete

它会将我重定向到/index.html#/

$window.open($window.location.pathname, '_self').$window.close();

最佳答案

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

是您可以使用的解决方法。您使用它时遇到的错误是:

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

这是正确的,您将不被允许关闭不是您创建的窗口。

请在此处查看完整说明:window.close and self.close do not close the window in Chrome

关于javascript - 关闭 Angular SPA 中的浏览器窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26363026/

相关文章:

javascript - 二级菜单粘在标题上

javascript - 如果需要,如何访问父作用域?

javascript - AngularJS 弹出聊天框

javascript - AngularJS +sails.js

javascript - Angular Controller 的动态属性

javascript - 如何在 then() 方法内发送响应,然后再发送另一个 then() 方法?

javascript - Angular 2 - 同时发出多个 HTTP 请求

javascript - 查找所选元素的所有 CSS 类规则(来自多个样式表)及其事件属性的列表

javascript - 当 Promise 被拒绝时,Promise 按顺序不会停止

javascript - Angular 1 : Above the Fold rendering