SoFunction
Updated on 2025-04-06

Example of simple image switching function implemented by JS [test available]

This article describes the simple image switching function implemented by JS. Share it for your reference, as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Picture switching</title>
</head>
<body><script language="JavaScript1.1">
<!--
var slidespeed=2000
var slideimages=new Array("images/","images/","images/","images/")
var imageholder=new Array()
var ie55=
for (i=0;i<;i++){
imageholder[i]=new Image()
imageholder[i].src=slideimages[i]
}
function gotoshow(){
=slidelinks[whichlink]
}
//-->
</script>
<img src="images/" name="slide" border=0 style="filter:progid:(MaxSquare=15,Duration=1)">
<script language="JavaScript1.1">
<!--
var whichlink=0
var whichimage=0
var pixeldelay=(ie55)? [0].duration*1000 : 0
function slideit(){
if (!) return
if (ie55) [0].apply()
=imageholder[whichimage].src
if (ie55) [0].play()
whichlink=whichimage
whichimage=(whichimage<-1)? whichimage+1 : 0
setTimeout("slideit()",slidespeed+pixeldelay)
}
slideit()
//-->
</script>
</body>
</html>

For more information about JavaScript, readers who are interested in reading this site's special topic:JavaScript image operation skills》、《Summary of JavaScript's movement effects and techniques》、《Summary of JavaScript switching effects and techniques》、《Summary of JavaScript Errors and Debugging Skills》、《Summary of JavaScript data structure and algorithm techniques》、《Summary of JavaScript traversal algorithm and skills"and"Summary of JavaScript mathematical operations usage

I hope this article will be helpful to everyone's JavaScript programming.