Home > Blockchain >  how to open links in _blank/ another page and override it to open different links in that particular
how to open links in _blank/ another page and override it to open different links in that particular

Time:02-01

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");
}

these functions are of 3 different buttons. i am giving the url as arg, it is working fine, but because of "_blank" every link is opening in a different window, i want the "_blank" but links should override that particular window only.

is it possible?

CodePudding user response:

May be you can use like below way: First Time use your code:

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

use this variable second time with below logic

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