The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Change background color when page re-loads?

  • # December 7, 2012 at 11:32 am


    Can anyone please suggest a simple method for randomly changing the background color after the user re-loads / re-visits a web page?


    # December 7, 2012 at 12:21 pm

    It’s going to be a JS solution.

    A quick google search will give you the answer.

    # December 7, 2012 at 9:06 pm

    Do you want a set of different colors or do you want the colors to be truly random?

    # December 7, 2012 at 9:31 pm

    Here’s an example for a truly random color

    # December 10, 2012 at 5:24 am = "#"+((1<<24)*Math.random()|0).toString(16);


    # December 10, 2012 at 6:31 am

    This reply has been reported for inappropriate content.

    This could be done with a backend language just as easily too. (I’d rather use a backend language too)

    # December 10, 2012 at 10:09 am

    Nice bit of code-golf @Hompimpa

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed