i've got some code - using jquery & javascript - that loads a random background image into a div element. the code is below. the trouble is, it loads a random image every time the page is loaded, when what i want is to just pick a random image ONCE each day
anyone any idea of how i'd go about doing this?
Code:<script type="text/javascript"> $(document).ready(function() { if ($(window).width() > 1200) { var randomImages = ['bgimage0_big', 'bgimage1_big', 'bgimage2_big', 'bgimage3_big']; var rndNum = Math.floor(Math.random() * randomImages.length); $("div#branding").css({ background: "url(css/images/" + randomImages[rndNum] + ".jpg) no-repeat" }); } else { var randomImages = ['bgimage0_small', 'bgimage1_small', 'bgimage2_small', 'bgimage3_small']; var rndNum = Math.floor(Math.random() * randomImages.length); $("div#branding").css({ background: "url(css/images/" + randomImages[rndNum] + ".jpg) no-repeat" }); } }); </script>



Reply With Quote


Bookmarks