Skwolven Posted November 12, 2020 Share Posted November 12, 2020 Site URL: https://fredfilms.com I have a custom script on my homepage that loads a different background image each time the page loads. It works great when I view my website within the squarespace editor, but now that the site is live it is doing something weird. I checked in multiple browsers and it's consistently having this same problem. When I refresh my browser it works great! The trouble is that if I navigate to the home page with any of the nav links or the logo in the main nav then I just get a grey background with no image. Any insights into this issue would be GREATLY appreciated. (I have more images than this in the actual page, but for brevity's sake I took most of them out here) <script type="text/javascript"> var images = /*//add image urls here in single quotes, the order does not matter//*/ ['https://static1.squarespace.com/static/5f32e3f1b490445685cb1d10/5f67c7c9ef095d17b781a722/5f67c7d40587154ff889354b/1600636891257/AdventureTime.jpg', 'https://static1.squarespace.com/static/5f32e3f1b490445685cb1d10/5f67c7c9ef095d17b781a722/5f67c7d4c9621301a2132b00/1600636888637/Bravest-Warriors-900x506.jpg', 'https://static1.squarespace.com/static/5f32e3f1b490445685cb1d10/5f67c7c9ef095d17b781a722/5f67c7dd84df667bd7f43922/1600636898493/castlevania3.jpg', 'https://static1.squarespace.com/static/5f32e3f1b490445685cb1d10/5f67c7c9ef095d17b781a722/5f90d3398363457e25a089be/1603326782909/Adventure+Time+4.jpg']; /*//this part chooses the image from the urls above//*/ document.getElementById("title").style.backgroundImage = 'url(" ' + images[Math.floor(Math.random() * images.length)] + '")'; </script> Link to comment
Skwolven Posted November 12, 2020 Author Share Posted November 12, 2020 OK, I fixed it by turning of Ajax loading, but if someone knows how to rewrite the script so it would work with Ajax enabled I'd be super appreciative! Link to comment
SpencerC Posted November 12, 2020 Share Posted November 12, 2020 Hi @Skwolven, Ajax loading can often affect the function of custom code, as mentioned here. It may not be possible to implement any code on these pages of your site while Ajax loading is enabled. Hope that helps! Skwolven 1 SPENCER CHRISTIECUSTOMER OPERATIONS ADVISORHE/HIM Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment