Random background images JS
-
Hello,
Is there a simple way to have a random background image on the Home page ?
I know it isn't a lay option but I guess it's something simple in javascript ? (but I don't know js so...)All I know is that it should begin like that :
(id:72 correspond to my landing page)<script> window.laytheme.on("newpageshown", function(layoutObj, type, obj){ if(type == "page" && obj.id == 72){ // Put all of your js, without document ready inside here } }); </script>
So basically not much... And add a class in html.
I found a lot of different codes online like those :
http://jsfiddle.net/mrwigster/36cL6/https://fredthewebguy.me/tutorials/load-random-images-page-load-jquery/
but can't make them to work... And I don't know if I should write the paths to the images as a link "http://..." or "/media/img.jpg"
Sorry for my vague message. But it seems a lot of people would to add that to their land page so it would be nice to have an easy solution somewhere.
Thank you very much !
Before you post:
Use the Search Feature. Maybe there is already a solution to your issue.
1. Update Lay Theme and all Lay Theme Addons
2. Disable all Plugins
3. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code ", click "Save Changes"
4. When using a WordPress Cache plugin, disable it or clear your cache.
Now see if your problem solved itself.
Go here, see if your problem is listed here:
Troubleshooting
When you post:
1. Post a link to where the problem is
2. If the problem is difficult to explain, post screenshots / link to a video to explain it
I don't answer or check forum DMs, please just post on the forum.