【问题标题】:Angular Typescript How to detect URL change on new window?Angular Typescript如何检测新窗口上的URL更改?
【发布时间】:2018-05-29 15:38:38
【问题描述】:

我使用的是最新的 Angular 6。我需要根据用户输入打开一个带有 URL 的新窗口。该 URL 具有指定的返回 URL。 返回 URL 完全加载后,我需要访问 DOM 并从中提取一个元素。

在我的服务中,我有以下代码

getNativeWindow() {
  return window;
}

该服务已被注入到如下功能的组件中

onSubmitAuthDetails() {
  console.log('onSubmitAuthDetails');
  this.nativeWindow = this.loginService.getNativeWindow();
  var newWindow = this.nativeWindow.open(this.userInput +
     '/Login?returnUrl=//AppLaunch&ia=1');
  newWindow.popstate = function (event) {
     console.log('event triggered', event);
  };
  console.log('Window opened done-');
}

新窗口出现在新窗口中,并根据工作流程,最终加载 AppLaunch 页面。 但是我无法弄清楚将捕获此事件的事件? popstate 不起作用。

是否有其他方式或其他事件我必须听?

【问题讨论】:

    标签: angular angular6


    【解决方案1】:

    这可能是因为 CORS。由于发起者与新发起的 URL 不同。

    【讨论】:

      猜你喜欢
      • 2013-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 2019-05-04
      相关资源
      最近更新 更多