Jump to content

I need code JavaScript auto Images and Link for Advetisment


haibec

Recommended Posts

Then, without showing us your codes, I believe you haven't created one yet.As a result, I made one which depict your requirement:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">#display {width:500px;line-height:30px;border:3px double #999;font-family:time,serif;font-size:16px;text-align:center;margin:20px auto 0px auto;padding:20px;}img{width:500px;height:450px;}#caption{width:500px;margin:auto;text-align:center;}</style><script type="text/javascript">function randShow(i){/***********Set the images you want to show here********************/var img1='http://h1.ripway.com/rangana/images/Picture1.png',img2='http://h1.ripway.com/rangana/images/Picture2.jpg',img3='http://h1.ripway.com/rangana/images/Picture3.jpg',img4='http://h1.ripway.com/rangana/images/Picture4.jpg',img5='http://h1.ripway.com/rangana/images/Picture5.jpg',img6='http://h1.ripway.com/rangana/images/Picture6.jpg',img7='http://h1.ripway.com/rangana/images/Picture7.jpg',img8='http://h1.ripway.com/rangana/images/Picture8.jpg',img9='http://h1.ripway.com/rangana/images/Picture9.jpg',/**********************End of your image's setting******************//***************Set the captions you want to be seen*****************/cap1='Caption for image1',cap2='Caption for image2',cap3='Caption for image3',cap4='Caption for image4',cap5='Caption for image5',cap6='Caption for image6',cap7='Caption for image7',cap8='Caption for image8',cap9='Caption for image9',/***************End of caption's setting**************************/delay=5, //Means you want it to change every 5 seconds.showimage=document.getElementById('display'), //ID of your div where you want the image be seen.showcaption=document.getElementById('caption'), //ID of your div where the caption should be seen.imgs=[img1,img2,img3,img4,img5,img6,img7,img8,img9], // Should depict on whats declared in images abovecaption=[cap1,cap2,cap3,cap4,cap5,cap6,cap7,cap8,cap8,cap9]; // Should depict on what's declared in caption above/****************No need to edit beyond this part***********************/// Script by: Raymond Angana// rangana in w3schools forum// Title: Dynamic image and caption every X seconds.// Parameters: imgN where N is the nth image.// capN where N is the nth caption.// show variable holds the id of the div holding the image// showcaption variable holds the id of the div holding the caption// This notice must stay intact./*******************End of notice*********************************/speed=delay*1000,showimage.innerHTML='<img src="'+imgs[i]+'" alt="myimage">',showcaption.firstChild.nodeValue=caption[i];i++;if(i==imgs.length) i=0;setTimeout(function(){randShow(i)},speed);}window.onload=function(){randShow(0);};</script></head><body><div id="display"> </div><div id="caption"> </div></body></html>

Hope it helps. Comments are added for you to understand the variables and function easily.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...