
javascript图片循环显示
四张图片循环显示,用setInterval达到效果,我写的代码怎么修改呢。<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transi...
四张图片循环显示,用setInterval达到效果,我写的代码怎么修改呢。<!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=gb2312" /><title>无标题文档</title><script language="javascript"> function img1(n){ if(n==1){ myform.imgflash.src="image/flower.jpg"; } if(n==2){ myform.imgflash.src="image/flower2.jpg"; } if(n==3){ myform.imgflash.src="image/s1.jpg"; } if(n==4){ myform.imgflash.src="image/s2.jpg"; } } window.setInterval("img1()", 3000);</script></head><body><form name="myform"><input type="image" name="imgflash"></form> </body></html>
展开
3个回答
展开全部
<html>
<head>
<title></title>
<script language="javascript">
var n = 1;
function img1() {
if (n == 1) { myForm.imgflash.src = "image/flower.jpg"; }
if (n == 2) { myForm.imgflash.src = "image/flower2.jpg"; }
if (n == 3) { myForm.imgflash.src = "image/s1.jpg"; }
if (n == 4) {
myForm.imgflash.src = "image/s2.jpg";
n = 0;
}
n++;
}
window.setInterval("img1()", 3000);
</script>
</head>
<body>
<form name="myForm">
<img id="imgflash"/></form>
</body>
</html>
<head>
<title></title>
<script language="javascript">
var n = 1;
function img1() {
if (n == 1) { myForm.imgflash.src = "image/flower.jpg"; }
if (n == 2) { myForm.imgflash.src = "image/flower2.jpg"; }
if (n == 3) { myForm.imgflash.src = "image/s1.jpg"; }
if (n == 4) {
myForm.imgflash.src = "image/s2.jpg";
n = 0;
}
n++;
}
window.setInterval("img1()", 3000);
</script>
</head>
<body>
<form name="myForm">
<img id="imgflash"/></form>
</body>
</html>
展开全部
<script language="javascript">
var curimgid=1;
var j;
function img1(){
j = curimgid%4
switch(j){
case 0:
case 1:
case 2:
case 3:
default:
}
curimgid++;
}
window.setInterval("img1()", 3000);
</script>
<div id="div1"></div>
var curimgid=1;
var j;
function img1(){
j = curimgid%4
switch(j){
case 0:
case 1:
case 2:
case 3:
default:
}
curimgid++;
}
window.setInterval("img1()", 3000);
</script>
<div id="div1"></div>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!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=gb2312" />
<title>
无标题文档
</title>
<script language="javascript">
var ct=0;
var img_arr = new Array("image/flower.jpg","image/flower2.jpg","image/s1.jpg","image/s2.jpg");
function img1() {
document.getElementById('imgflash').src = img_arr[ct];
ct++;
if(ct>3){ct = 0;}
}
window.setInterval("img1()", 3000);
</script>
</head>
<body>
<input type="image" id="imgflash" src="image/flower.jpg">
</body>
</html>
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>
无标题文档
</title>
<script language="javascript">
var ct=0;
var img_arr = new Array("image/flower.jpg","image/flower2.jpg","image/s1.jpg","image/s2.jpg");
function img1() {
document.getElementById('imgflash').src = img_arr[ct];
ct++;
if(ct>3){ct = 0;}
}
window.setInterval("img1()", 3000);
</script>
</head>
<body>
<input type="image" id="imgflash" src="image/flower.jpg">
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询