Opening 2 new windows?

Hi
When an image is clicked, I want to open two new windows: first at the same window and the second as a new tab (opening as 2 new windows is also fine).

What I did is:

$w.onReady( function () {

$w('#image1').link = "***"; 
$w('#image1').target = "_blank"; 

});

export function image1_click(event) {
wixLocation.to (“***”);
}

It works but I don’t feel comfortable with it, and I’m not sure it always work. Is there another idea?

I also thought to open a new window and use Router to open another window on loaded, but you can’t use wixLocation on backend.

You can do it this way:

import wixLocation from ‘wix-location’;

$w.onReady( function () {

$w('#image1').link = "https://www.google.com"; 
$w('#image1').target = "_blank"; 

});

export function image1_click_1(event) {
//Add your code for this event here:
wixLocation.to(“http://yahoo.com”);
$w(‘#image1’).target = “_blank”;
}

You will get first link opening in a new tab and second (onClick fn) will open the link in the same tab.

The second .target is not necessary and I think it does nothing. Am I wrong?

@jonatandor35 Think you are right as the code would have moved the user onto Yahoo page already.

@givemeawhisky and anyway the link is already set to “_blank”. No need to set it again.