Jump to content


  • Posts

  • Joined

  • Last visited

Nomuarch's Achievements

Level 1

Level 1 (1/20)



  1. I have used this answer provided from a different site: <script type="text/javascript"> // Randomly set background color of Announcement Bar Wrapper. const headerABW = document.querySelector('.header-announcement-bar-wrapper'); const colorArray = ["#003D44", "#096570", "#164487", "#FFFF99", "#2252A0", "#72220D"]; headerABW.style.backgroundColor = colorArray[Math.floor(Math.random() * colorArray.length)]; </script> Thanks to all who have answered here.
  2. Site URL: https://commercial.jrbullock.com/ Greetings, I am trying to have a different header colour each time the page loads. I have patched this code together from a few sources. I am using an array for the colours. I think I am close to a solution but I have run out of knowledge. <script type="text/javascript"> //colour change on refresh var colorArray = ["#003D44", "#096570", "#164487", "#FFFF99", "#2252A0", "#72220D"]; const headerr = document.querySelector('.header-announcment-bar-wrapper') function getRandomColor() { return colorArray[Math.random() * colorArray.length | 0]; } console.log(getRandomColor()); window.addEventListener('load', ()=> { headerr.style.backgroundColor * getRandomColour }); </script> Any help would be greatly appreciated.
  • 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.