Hi,
a customer wish, if possible, to pick a random background image from a list.
I've found this script and customized:
<script>
const images = [
'url("/custom/login/Sfondo-bottiglia.jpg")',
'url("/custom/login/DJI_0585_small.jpg")',
];
// Function to change the background image randomly
function changeBackground() {
const randomIndex = Math.floor(Math.random() * images.length);
document.body.style.backgroundImage = images[randomIndex];
}
// Change the background on page load
changeBackground();
</script>
but its not working, the image stay as configured in the background header.
Can anyone more skilled with javascript give me some suggestion?
Or if there is an alternative for this customization?
TIA
Regards,
Andrea Del Bravo