Hello, I’ve tried to place the above code into my site, but it only wants to repeatedly select one of the url’s even though I have multiple urls placed in the “const allUrls” section.
Any ideas on how to solve this issue and have the code “recognize/consider” all the listed urls?
All you need to recreate this function is a blank Wix-Page inside your Wix-Editor and 2 buttons on stage (button1 & button2) and of course the shown code.
That’s very close to what I’m trying to do…but, is there a way to hide the randomly generated link so that I can overlay it on a custom graphic/image? And make the graphic/image “appear” to be the button.
And/or is there a way to have the randomization only occur once the button is clicked instead of upon refreshing the page?
Sweet this is working how I wanted it to, thank you…But right now the randomizing button is place over an image/icon I am using and I just made the button transparent so it looks like your clicking the image and not the button.
Do I have to do it this way or can I use an image in place of the button with some similar code? If this makes sense?
I have an Image which i want to be clickable (understood).
No need to overlay your images with buttons (no need to generate fake Icon-Buttons).
There are 3 different ways of how to solve it.
a) your way → i call it fake-way.
b) wix provides you buttons with integrated icons (as of my knowledge) → but maybe still not a good solution.
c) Simply turning an IMAGE → into a BUTTON by code (maybe the best solution and most flexible).
Once clicked onto my image —> …continue your detailed description…
??? —> i want to be navigated to a random generated site?
??? —> i want to show a random pic?
??? —> i do not want to open a new tab, instead i want to show in same window?
??? —> …and so on…
The more detailed you describe your issue/setup → the more accurate and precise will be the answer / result.
((The overall goal is to have an icon/image on my site which someone can click on and it will take them to a random page within my sites url database))
So yes you basically have it right… If I can do it easily enough I would like to turn an image into a button so that I don’t have to do it the fake-way.
And yes, once clicked on my image "I do not want to open a new tab, instead I want to show the random page from my site in same window.
Hmm, when I replace your new code for the old one and I change the image name to match my image own image tag there is nothing clickable, like it’s not recognizing the image as a button?!
Hey, WIX put me on a 15 hour timeout, but i’m back now…
So if you are still willing to help, here’s the current problem when I try to use the new code…
No page change when the button is clicked, but it looks like the button is working as it should be from what I can see in the developer console (when I click the image it shows one of my listed urls) But why won’t the button click change the page?
Tested in Editor-Preview, take a look onto console-logs…
Testing it inside the Wix-Editor won’t do the navigation to other sites.
If you want to see the navigation is working or not, you will have to test it on LIVE-SITE.
Just changed your pic against mine… and the URL-DATA…