Image Slideshow (Photo credit: Wikipedia) |
Code for Creating Slideshow with Links on Image
Just copy and paste the code below where you want to place slideshow and change the location of the images.
<script type="text/javascript">
var i = 0;
var image = new Array();
// LIST OF IMAGES
image[0] = "image-1.png";
image[1] = "image-2.png";
image[2] = "image-3.png";
var k = image.length-1;
var caption = new Array();
// LIST OF CAPTIONS
caption[0] = "Caption for the first image";
caption[1] = "Caption for the second image";
caption[2] = "Caption for the third image";
var link= new Array();
// LIST OF LINKS
link[0] = "http://www.siteforinfotech.com/";
link[1] = "http://www.siteforinfotech.com/p/tutorial.html";
link[2] = "http://www.siteforinfotech.com/p/mcqs.html";
function swapImage(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img = document.getElementById("slide");
img.src= image[i];
var a = document.getElementById("link");
a.href= link[i];
if(i < k ) { i++;}
else { i = 0; }
setTimeout("swapImage()",5000);
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
swapImage();
});
</script>
<table style="border:none;background-color:transparent;">
<tr>
<td>
<a name="link" id="link" href="http://www.siteforinfotech.com/" target="_blank"><img name="slide" id="slide" alt
="my images" height="285" width="485" src="image-1.png"/></a>
</td>
</tr>
<tr>
<td align="center"style="font:small-caps bold 15px georgia; color:blue;">
<div id ="mydiv"></div>
</td>
</tr>
</table>
Code for Creating Slideshow with Links on Caption
Just copy and paste the code below where you want to place slideshow and change the location of the images.
<script type="text/javascript">
var i = 0;
var image = new Array();
// LIST OF IMAGES
image[0] = "image-1.png";
image[1] = "image-2.png";
image[2] = "image-3.png";
var k = image.length-1;
var caption = new Array();
// LIST OF CAPTIONS
caption[0] = "Caption for the first image";
caption[1] = "Caption for the second image";
caption[2] = "Caption for the third image";
var link= new Array();
// LIST OF LINKS
link[0] = "http://www.siteforinfotech.com/";
link[1] = "http://www.siteforinfotech.com/p/tutorial.html";
link[2] = "http://www.siteforinfotech.com/p/mcqs.html";
function swapImage(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img = document.getElementById("slide");
img.src= image[i];
var a = document.getElementById("link");
a.href= link[i];
if(i < k ) { i++;}
else { i = 0; }
setTimeout("swapImage()",5000);
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
swapImage();
});
</script>
<table style="border:none;background-color:transparent;">
<tr>
<td>
<img name="slide" id="slide" alt ="my images" height="285" width="485" src="image-1.png"/>
</td>
</tr>
<tr>
<td align="center"style="font:small-caps bold 15px georgia; color:blue;">
<a name="link" id="link" href="http://www.siteforinfotech.com/" target="_blank"><div id
="mydiv"></div></a>
</td>
</tr>
</table>
You Might also view the following Related Posts
إرسال تعليق
Click to see the code!
To insert emoticon you must added at least one space before the code.