Button link target "_self" not working

@wix - I know this is a small issue but it would be great of you guys could put it in the queue to be fixed.

When setting a URL with code and the target to “_self” so that it opens in the same tab it doesn’t work, for instance:

let url = 'https://www.wix.com/corvid/forum/community-discussion'
$w("#buttonGo").link = url;
$w("#buttonGo").target = '_self';

I’m building a dynamic URL hence using code instead of the UI to set the link. Also, even when setting the target to “_blank” or just not defining it the button doesn’t work on the first click, it has to be clicked a second time before it works. And no, my on-click handler is not set to onDblClick, I checked.

Thank you
Tiaan

1 Like

The reason is because .target according to wix "

Set an element to open an external web link in a new browser page when clicked" so it only sets the link when clicked that why you have to click it a second time because .target only initializes after the first time the button has been clicked. But after that I ran into a problem the _blank works then but if there is any code inside button on click event like your own code the on _self does not work even if you do

$w("#buttonGo").link = url;
$w("#buttonGo").target = '_self';
on the onReady() function