Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    logo image changing on refresh

    i was wondering if there is a code that any of you know that if i have different multiple images of my logo and everytime someone refreshes the page it changes randomly to one of the images everytime? Can this be done with javascript and if so could you please pass on the code, or could this be done with something like css or html? I don't see either css or html doingthat but maybe im missing something

    thank you
    Last edited by 1234m; 12-23-2009 at 04:08 PM.

  • #2
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In my opion,it is unrealistic if you wanna process in client side.

    suggest you process on server side.



    -----------------------------------------
    http://www.buceshi.com

  • #3
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    346
    Thanks
    9
    Thanked 51 Times in 50 Posts
    Probably you want it like below?
    I haven't tested yet,
    but you should rename the files to
    logo1.jpg, logo2.jpg, ... up to logo4.jpg
    (see the total_images variable)

    PHP Code:
    <script type="text/javascript">
    var
      
    total_images=5;

    function 
    rand_logof(){
      var
        
    a=Math.floor(total_images*Math.random());
      
    document.getElementById("logo").src="logo"+a+".jpg";
    }

    </script>
    </head>

    <body onload="rand_logof();">
      <img id="logo" src="" />
    </body>
    </html> 
    Last edited by hdewantara; 01-01-2010 at 07:18 PM.

  • #4
    New Coder
    Join Date
    Dec 2009
    Posts
    96
    Thanks
    1
    Thanked 2 Times in 2 Posts
    I've searched a script like this before and I found this one (was still amoung my favorites lol). I actually didn't use it in the end, but maybe it's useful for you.

    Note: it's not mine, just pointing out where you might find it.

    Ranom Image Script

    If the above example isn't useful or exactly what you want, maybe this'll do it!


  •  

    Posting Permissions

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