【问题标题】:how to open links in _blank/ another page and override it to open different links in that particular window in Angular如何在 _blank/ 另一个页面中打开链接并覆盖它以在 Angular 的特定窗口中打开不同的链接
【发布时间】:2023-01-31 22:00:59
【问题描述】:
const newChildWindow = window.open(
              url, "_blank", `width="${altScreen.availWidth}", height="${altScreen.availHeight}"`
            );
            newChildWindow?.resizeTo(altScreen.availWidth, altScreen.availHeight);
            newChildWindow?.moveTo(altScreen.left, 0);
fun1(){
    this.doSetup("http://www.google.com");

  }
  fun2(){
    this.doSetup("http://www.twitter.com");

  }
  fun3(){
    this.doSetup("http://www.linkedin.com");

  }

这些功能有 3 个不同的按钮。 我将 url 作为 arg 给出,它工作正常,但由于“_blank”每个链接都在不同的窗口中打开,我想要“_blank”但链接应该只覆盖那个特定的窗口。

是否可以?

【问题讨论】:

    标签: angular typescript


    【解决方案1】:

    也许你可以像下面这样使用: 第一次使用您的代码:

    const newChildWindow = window.open(
                  url, "_blank", `width="${altScreen.availWidth}", height="${altScreen.availHeight}"`
                );
                newChildWindow?.resizeTo(altScreen.availWidth, altScreen.availHeight);
                newChildWindow?.moveTo(altScreen.left, 0);
    

    使用以下逻辑第二次使用此变量

    newChildWindow.location.replace("http://www.w3schools.com");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-15
      • 1970-01-01
      • 2019-07-22
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多