Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Change background color when page re-loads?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #41218
    Rugg
    Participant

    Hello,

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

    Thanks

    #116676
    Paulie_D
    Member

    It’s going to be a JS solution.

    A quick google search will give you the answer.

    #116672
    tbwiii
    Participant

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

    #116673
    tbwiii
    Participant

    Here’s an example for a truly random color http://jsfiddle.net/djHyV/

    #116732
    Taufik Nurrohman
    Participant
    document.body.style.background = "#"+((1<<24)*Math.random()|0).toString(16);

    Demo: http://jsfiddle.net/tovic/djHyV/2/

    #116743
    tbwiii
    Participant

    Nice bit of code-golf @Hompimpa

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.