Jump to content

randomly cycle a banner background image on page load?

Recommended Posts

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

nevermind! I got it to work by taking the image out of the banner and setting background properties with CSS. I've seen some other folks struggling with this so here's what worked for me:


  background: #cacaca;
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-blend-mode: multiply;

-style your background however you want. I like the parallax effect and added an overlay so the text on top would stand out more


footer code injection:

<script type="text/javascript">

    var images = ['image.jpg', 'image2.jpg', 'image3.jpg', 'image4.jpg', 'image5.jpg'];              
    document.getElementById("page").style.backgroundImage = 'url(" ' + images[Math.floor(Math.random() * images.length)] + '")';

-you'll have to find the urls for your images and replace image.jpg above with the full url, and replace "page" with whatever your page id is.

good luck!


Link to comment
  • 1 year later...
  • 7 months later...
14 hours ago, AndrejB said:

@Skwolven Thanks for sharing the script. I'm trying to implement it on SQSP 7.1 with no luck. Can someone help?

You want this for Banner Image or Banner Video? With banner image, I remember I solved a similar case.

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.