Results 1 to 3 of 3

Thread: Random Headers on a HTML Page

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Random Headers on a HTML Page

    I have 5 images set up to fit within the header on my web page. I want each time the pages loads to randomly display 1 of the 5 images in the header... Is this complicated? Anyone got any ideas?

    Thanks,
    Tom

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    In Javascript? Not really.
    Code:
    <img src="image1.png" name="headerImage">
    <script type="text/javascript">
    window.onload = function() {
      var images = ["image1.png", "image2.png", "image3.png"]; // Add more if you like
      document.images['headerImage'].src = images[Math.floor(Math.random() * images.length)];
    };
    </script>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Like mess.be?

    What he said. ^ UP THERE ^

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
  •