I've added 9 backgrounds in my SiteAssets and I want them to randomly appear when the user clicks on any of the pages?
I've tried the following:
Before the DOCTYPE
<?php
$bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // array of filenames
$i = rand(0, count($bg)-1); // generate random number size of the array
$selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
?>
In the head section or in the body section
<style type="text/css">
<!--
body{
background: url(images/<?php echo $selectedBg; ?>) no-repeat;
}
-->
</style>
but it didn't work. I think it's because I'm missing the CSS tag for the background in Sharepoint.
Could you help with this?
Thank you in advance.
Edit: