Hello!
Thank you to anyone who takes time to read/ help. I’m looking to randomize certain elements upon loading every new page of my website. I have pairs of color coordinated logos+background. ex. red background+red logo, blue background+blue logo, etc. The logo is in the header, and the background would apply to every page. does anyone have good direction on how to do this? I’m not sure how to set the image path from Wix’s UI.
Thanks again!
Hi,
Please clarify your question and explain in details, because I don’t understand what exactly you’re trying to do.
I would like the background image and the image in my header to randomize upon loading the webpage. For example, the background and the company logo are both red, i refresh the page and they are both blue, i refresh the page again and this time its green, but i am trying to make it random.
i already have all images made in different colors, and uploaded to my image collection on wix.
Take a look at this example here…
https://russian-dima.wixsite.com/meinewebsite/random-numbers-strings
And learn how to generate some random values.
Hi Rawn,
The way i would do it.
Make an array with the color’s / backgrounds you want to be able to shown.
const array =
[{
image:imagesource1,
color:color1
},{
image:imagesource2,
color2
}]
Then as you load a page, generate a random number like @russian-dima said.
Be sure the random number isn’t higher then the array length
Then use that random number to select the a background/color and use it to change the page background.
$w("#page").background.src
Kind regards,
Kristof