Saturday, 1 March 2014

Slide Show with Caption Operation using Java Script

Ans:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Slide Show with Caption</title>
 
<script type="text/javascript">
var i = 0;
var image = new Array();  
// LIST OF IMAGES
image[0] = "Image/1.jpg";
image[1] = "Image/2.jpg";
image[2] = "Image/3.jpg";
image[3] = "Image/4.jpg";  
var k = image.length-1;  
var caption = new Array();
// LIST OF CAPTÄ°ONS
caption[0] = "Caption for the first image";
caption[1] = "Caption for the second image";
caption[2] = "Caption for the third image";
caption[3] = "Caption for the fourth image";
function swapImage(){
var el = document.getElementById("mydiv");
el.innerHTML=caption[i];
var img= document.getElementById("slide");
img.src= image[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>

   
</head>
<body >
    <form id="form1" runat="server">
    <center>

    <div>
    <table style="border:3px solid #00aaff;background-color:#00aaaa;">
<tr>
<td>
<img name="slide" id="slide" alt ="my images" height="285" width="485" src="Image/1.jpg"/>
</td>
</tr>
<tr>
<td align="center"style="font:small-caps bold 15px georgia; color:blue;">
<div id ="mydiv"></div>
</td>
</tr>
</table>
    </div>
    </center>
        </form>
</body>
</html>

No comments:

Post a Comment