User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 392,271 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,665 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Alternating backgrounds?

Join Date: Aug 2006
Posts: 1
Reputation: sjaak is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sjaak sjaak is offline Offline
Newbie Poster

Question Re: Alternating backgrounds?

  #15  
Aug 28th, 2006
Originally Posted by alpha_foobar View Post
Actually, using this type of mechanism, the images are loaded on demand....

For an example of ondemand loading of images, check out this page: http://homepages.ihug.co.nz/~jlittle/imgs/images.html

You'll see images are loaded when you click on them.. and if your connection is slow enough, you should also see a please wait message (though I've found this doesn't always seem to work so well in IE).

 
<html>
<script type="text/javascript">
    var images = new Array("a.png", "b.png", "c.png");
 
    function randomImageSelector(){
        var imageNode = document.getElementById("randomImage");
 
        var index = Math.floor(Math.random() * images.length);
        imageNode.src = images[index];
        imageNode.alt = images[index];
    }
 
    window.onload = function(){
        randomImageSelector();
    };
</script>
 
<body>
 
<img src="placeHolder.png" id="randomImage"/>
 
</body>
</html>
 

A way of 'always' getting a different image is to implement a time based seed... this can be calculated in to avoid random providing the same image each load... a large set of images to choose from will also help.

******************************
I understand your answer is from quit a while ago, but since I'm new on this forum I'm responding just now. I too want to have alternating pictures when reloading in a non-server-based way, but realy alternating and no repeating of the same image. You write about a time based seed. Can you tell me more about that. Or is ther a totally different way to do it. After all, your method IS randomizing, and not alternating!
Thanx, Sjaak
Reply With Quote  
All times are GMT -4. The time now is 8:09 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC