Monthly Archives: April 2010

Image change with refresh or load a page by javascript

<SCRIPT LANGUAGE="JavaScript">
var theImages = new Array()

      theImages[0] = 'iphone-FASTEST.jpg'
      theImages[1] = 'apple-3gs-0.jpg'
      theImages[2] = 'apple-iphone-3gs-2-0.JPG'
      theImages[3] = 'iphone-accessibility.jpg'
      theImages[4] = 'iphone-cutcopypaste.jpg'
	  
	  
	  

var j = 0
var p = theImages.length;
var preBuffer = new Array()

for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));

function showImage(){
if(whichImage==0){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=452 height=181></a>');
}
else if(whichImage==1){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=452 height=181></a>');
}
else if(whichImage==2){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=452 height=181></a>');
}
else if(whichImage==3){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=452 height=181></a>');
}
else if(whichImage==4){
document.write('<a href ="link.html"><img src="'+theImages[whichImage]+'" border=0 width=452 height=181></a>');
}


}

</script>


The call this where u want to show the image

 <div>
	  Image here
	  
	  <script>showImage();</script>

	  </div>

%d bloggers like this: