Results 1 to 3 of 3

Thread: random banner image change on page load each time

  1. #1
    Join Date
    Mar 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default random banner image change on page load each time

    hi to all!

    i am looking for some JS script using this i can change banners everytime i load one page. every time i load the page the banner image will get change automatically.

    can anyone help me on this script? its very urgent.


    Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Ok, you want to put this in the <head> section of your code.
    Blue: The number of your headers -1
    Magenta: The id of your header(or the banner's id).
    Green: The image with the <img> tag.
    You can add more if statements depending on your images.
    Code:
    <script type="text/javascript">
    // Generate a Random Number
    var movieDis; //global variable
    var number = 2; //your number of videos -1
    var randomnumber = Math.round(Math.random()*number+1); //generate a random number between 1-number+1
    movie(randomnumber, 'div');
    
    //Functions to write out the correct flash movie resource.
    function movie(num, el){
    if(num == 1){
    movieDis = "image1";
    } else if(num == 2){
    movieDis = "image2";
    }else if(num == 3){
    movieDis = "image3";
    } else {
    movieDis = "There was an error. Please try again."; //error
    }
    document.getElementById(el).innerHTML=movieDis;
    }
    </script>
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2008
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for your reply!

    but it not working, as i think this code is incomplete. can u recheck and get back to me, there is nothing for body section, without that how can a page display image?

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
  •