Background image slideshow javascript source code

Here is the code for background image slideshow using javascript and css.

check out the code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="en-us">
<style>
body{
background-repeat: no-repeat;
background-position: 50 50;
}
</style>
<script >
//Specify background images to slide
var imgs=new Array()
imgs[0]="img1.jpg";
imgs[1]="img2.jpg";
imgs[2]="img3.jpg";
//Specify interval between slide (in miliseconds)
var speed=2000
//preload images
var processed=new Array()
for (i=0;i<imgs.length;i++){
processed[i]=new Image();
processed[i].src=imgs[i];
}
var inc=-1;
function slideimg(){
if (inc<imgs.length-1)
inc++;
else
inc=0;
document.body.background=processed[inc].src;
}
if (document.all||document.getElementById)
window.onload=new Function('setInterval("slideimg()",speed)');
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="table1" height="381">
	<tr>
		<td>
			<p>This is just dummy text</p>
			<p>This is just dummy text</p>
			<p>This is just dummy text</p>
			<p>This is just dummy text</p>
		</td>
	</tr>
</table>
</body>
</html>

You can use it for any elements background.

hope it will be useful.
thanx n regards,
Nikhil Ughade
Web Designer
[Pune]

Advertisements

Pure CSS div based form design / form layout

Pure CSS div based form design / form layout

Pure CSS div based form design / form layout

Pure CSS div based form design / form layout

Read more of this post

%d bloggers like this: