Angular - 允许window.open打开新窗口而不是弹出窗口

时间:2018-04-15 15:28:19

标签: javascript angular window.open

我正在尝试在新标签页中打开window.open。新标签基本上是一个PDF文件,会提示用户下载。

这是我的Angular 4代码:

download() {
    const data = {html: this.template.toArray()[0].nativeElement.innerHTML};
    this.authService.generateResume(this.template.toArray()[0].nativeElement.innerHTML).subscribe(res => {
      const path: string = res.success;
      const uri = path.substring(path.lastIndexOf('/'), path.length);
      window.open('http://example.com/pdf' + uri, '_blank');
    })
  }

我理解window.open被视为弹出窗口。

我们如何解决这个问题?

1 个答案:

答案 0 :(得分:-3)

要打开新网页,请尝试使用:

位置。取代( “// URL”);