I've looked on other posts and have found answers to this question but none of them have ever worked. My main problem is that the button will link to one particular website in my list. Does anyone have any ideas? If so, could you please help? Below is the code that I have already found.
![](https://static.wixstatic.com/media/a27d24_bb5a5cc5b0a447c983da39e0d2903e52~mv2.png/v1/fill/w_980,h_351,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/a27d24_bb5a5cc5b0a447c983da39e0d2903e52~mv2.png)
@Lior Wiseman Im not very good with code and don't really understand your answer. I've tried to do it and it does change the website but only every 2-4 times. Could you please help me to understand and/or write me an example line of code?
Hi MLG Vids,
Since you are running this logic in the onReady function, what you actually doing is running it once. so the logic of putting a random link is fine, however it will only run once the page is loaded and never again.
I would suggest one of two ways:
1. putting the logic inside the button onClick event, and using wixLocation.to to navigate to random URL, which will ensure it will "reRoll" again after each click.
2. change the button link property onMouseIn event. which don't help with keyboard navigation but its just another option you can mess around with.
Hope that helps!
Thanks for the help but that still didn't work
setTimeout(function() {$w('#button1').link = allUrls[randomIndex]}, 100) might work