Hello, I have looked on the internet for this code and tried every single person’s code and nothing seems to work. I’m copying a code that I found that seems to be on the right track, yet when implemented, the button is not clickable.
I want to have a button that when a user clicks the button, it opens up a random link from the list in a new tab. I want the button to open up a different random link each time the button is clicked. Here is the code that I tried:
import wixLocation from'wix-location';let allUrls =[
"http://www.cameronsworld. net",
"http://www.pictureofhotdog. com",
"http://www.breadfish. nl",
"http://www.catwig. com",
"http://www.loopedforinfinity. com",
"http://www.existentialcrisis. com",
"http://www.gurka. se"]
;exportfunction button3_click(event){
let randomIndex = Math.floor(Math.random()*(allUrls.length -1));
$w("#button3").link = allUrls[randomIndex];
$w("#button3").link
wixLocation.to($w("#button3").link);
}
Note that I had to “break” the links since this forum was not allowing me put links in my post.
Thank you if you are able to fix this code!!