5

JavaScript code to create an image slideshow

File name: ss.html:

< !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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Practical 1 - CST  </title>
<script type="text/javascript">
<!--
//preload images
var image1=new Image()
image1.src="images/img1.jpg"
var image2=new Image()
image2.src="images/img2.jpg"
var image3=new Image()
image3.src="images/img3.jpg"
var image4=new Image()
image4.src="images/img4.jpg"

//-->
</script>
<style type="text/css">
<!--
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #003399;
}
body {
	background-color: #999999;
	margin-left: 50px;
	margin-top: 50px;
	margin-right: 50px;
	margin-bottom: 50px;
}
-->
</style></head>
<body>
<h1>Practical 1  - CST</h1>
<h2>	<strong>Aim:</strong> Write a JavaScript code to create Image Slide show.</h2>

<p><a href="javascript:slidelink()"></a></p>
<p>
    <script type="text/javascript">
<!--
var step=1
var whichimage=1
function slideit(){
if (!document.images)
return
document.images.slide.src=eval("image"+step+".src")
whichimage=step
if (step&lt;4)
step++
else
step=1
setTimeout("slideit()",1800)
}
slideit()
function slidelink(){
if (whichimage==1)
window.location="images/img1.jpg"
else if (whichimage==2)
window.location="images/img2.jpg"
else if (whichimage==3)
window.location="images/img3.jpg"
else if (whichimage==4)
window.location="images/img1.jpg"
}
//-->
    </script>

    </p>
Click on the image to see it.

</body>
</html>
Filed in: Computer Geeks

(Discover ALL of My Hidden Free Traffic Sources...)

"Your privacy is assured - We won't share your information with anyone"


Recent Posts

5 Responses to "JavaScript code to create an image slideshow"

  1. Jon says:

    nice code. thanks for sharing.

  2. Yasin says:

    Thanx. this will be my first practical in CST

  3. Yasin says:

    Why dont u show the working of this script on the website it self…

  4. Gabe says:

    Is there anyway to control the time, for how long each of the images is displayed? I would like the images to be displayed for 5 seconds each.

Leave a Reply for "JavaScript code to create an image slideshow"

Submit Comment

© 2012 Internet Geeks. All rights reserved. XHTML / CSS Valid.