1.

Solve : Image that changes with every refresh??

Answer»

I want a banner that changes to a different image each time the page is loaded. How do I get this?That is commonly done in JavaScript. GO to your favorite JavaScript HANGOUT  and LOOK for one that does it on refresh. There are many. Just Google it.

Something like that can be done in PHP
PHP Random Image Rotation Here's a javascript solution I've used on one of my sites.  It uses MooTools - so you need to load that library first.

Code: [Select]// Arrange random artwork - MooTools must ALREADY be loaded
baseUrl = "http://some.domain.com/images/random/"; // web URL to the directory CONTAINING the images

var choices = [
               "image1.png",
               "image2.png",
               "image3.png",
               "image4.png",
               "image5.png"
              ]; // an array containing all the images to be used in the random selection

var artworkLocations = $$('.randomimg'); // this is the class name to apply to the div that will hold the image
$each(artworkLocations, function(value, key){
  value.style.backgroundImage = "url("+ baseUrl + choices.getRandom()+")";
});
And the HTML:

Code: [Select]<div class="randomimg"></div>



Discussion

No Comment Found