[solved] any ideas to improve the responsiveness of an random button?

Hi,
I’ve been tinkering with some code: you click on a button and it loads a new randomly chosen page from my site in the same tab. It works but it has a very variable reactivity… sometimes it takes 6/7 clicks to load the link. and on mobile too, sometimes more. Would you have any ideas to improve the responsiveness of the button?
Thanks :slightly_smiling_face:

const allUrls = [“/1”,“/2”,“/3”];
export function buttonA_click(event) {
$w(“#buttonA”).target = “_self”;
$w(‘#buttonA’).link = allUrls[Math.floor(Math.random() * (3))];
}

You should assign the link before the click;

const allUrls = ["/1","/2","/3"];
$w.onReady(() => {
    $w("#buttonA").target = "_self";
    $w('#buttonA').link = allUrls[Math.floor(Math.random() * (3))];
})

Grazie grazie ! it’s works