SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face Random Background Image & Colour

    Hello - JavaScript newbie here,

    I am tring to load a random background image & colour. (The image is aligned to the left of the page and the background colour is needed to match the image)

    I am able to load the random background image
    But, can not get the background colour working.

    Here is what I have so far:

    random_number= Math.floor(Math.random()* 3+1 );
    var mycol="#4c5d40";
    if (random_number==1) {
    image="images/img-1.jpg";
    }
    if (random_number==2) {
    image="images/img-2.jpg";
    mycol="#249a88"
    document.bgColor=(myCol)
    }
    if (random_number==3) {
    image="images/img-3.jpg";
    }



    // End -->
    </SCRIPT>



    </head>
    <body onload="document.body.background = image">

  2. #2
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Kammel can't thank you enough! It works beautifully


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •