How to open link in same tab and same window

Hi there!

I’m making a website as a hobby. I’m making good progress but have something that I don’t know how to solve.
I’ve got this piece of code to take me to a random page by pressing a button. That works fine. But it opens in a new tab. As soon as i return to the button page, the page hasn’t refreshed, which means that the button takes me to the same page, instead of a random other one.

I thought that the best way to solve this, is that the button takes me to a random page in the same tab. as soon as you return to the button page, the page is refreshed automatically.

Any thoughts on how to make this piece of code take me to a link in the same tab? Tried out some things with “_self”; but it doesn’t seem to work.

const allUrls = [
 'https://example. com',
 'https://example. com',
 'https://example. com', 

];

$w.onReady(function(){
 const randomIndex = Math.floor(Math.random() * (allUrls.length - 1));
    $w('#button4').link = allUrls[randomIndex];
});

Thanks in advance!!

You can find your answer in the documentation. See the target property of the Button element.