javascript图片循环显示
解决时间 2021-04-21 02:43
- 提问者网友:捧腹剧
- 2021-04-20 07:25
四张图片循环显示,用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>
最佳答案
- 五星知识达人网友:舊物识亽
- 2021-04-20 09:04
我有我做好的JavaScript代码 只要修改 图片的路径就可以用了 QQ: 170331773
全部回答
- 1楼网友:何以畏孤独
- 2021-04-20 12:14
<SCRIPT language=JavaScript>
<!-- // BannerAD
var bannerAD=new Array();
var bannerADlink=new Array();
var adNum=0;
bannerAD[0]="dianying/未来城1.gif";
bannerADlink[0]=" http://bbs.blueidea.com/archiver/tid-827032.html";
bannerAD[1]="dianying/回龙观社区电影1.gif";
bannerADlink[1]=" http://zhidao.baidu.com/question/783323.html";
bannerAD[2]="dianying/望京社区3.gif";
bannerADlink[2]="E:\图片收藏\aa.htm";
bannerAD[3]="dianying/01.gif";
bannerADlink[3]=" http://www.baidu.com/s?wd=%BB%BB%CD%BC%B4%FA%C2%EB&lm=0&si=&rn=10&tn=sitehao123&ie=gb2312&ct=0&cl=3&f=1&rsp=4";
bannerAD[4]="dianying/未来城2.gif";
bannerADlink[4]=" http://www.baidu.com/s?wd=%BB%BB%CD%BC%B4%FA%C2%EB&lm=0&si=&rn=10&tn=sitehao123&ie=gb2312&ct=0&cl=3&f=1&rsp=4";
bannerAD[5]="dianying/未来城3.gif";
bannerADlink[5]=" http://www.baidu.com/s?wd=%BB%BB%CD%BC%B4%FA%C2%EB&lm=0&si=&rn=10&tn=sitehao123&ie=gb2312&ct=0&cl=3&f=1&rsp=4";
bannerAD[6]="2004112517615.jpg";
bannerADlink[6]=" http://www.baidu.com/s?wd=%BB%BB%CD%BC%B4%FA%C2%EB&lm=0&si=&rn=10&tn=sitehao123&ie=gb2312&ct=0&cl=3&f=1&rsp=4";
bannerAD[7]="load_pic277.jpg";
bannerADlink[7]=" http://www.baidu.com/s?wd=%BB%BB%CD%BC%B4%FA%C2%EB&lm=0&si=&rn=10&tn=sitehao123&ie=gb2312&ct=0&cl=3&f=1&rsp=4";
bannerAD[8]="load_pic2229.jpg";
bannerADlink[8]=" http://www.baidu.com/s?wd=%BB%BB%CD%BC%B4%FA%C2%EB&lm=0&si=&rn=10&tn=sitehao123&ie=gb2312&ct=0&cl=3&f=1&rsp=4";
bannerAD[9]="load_pic2666.jpg";
bannerADlink[9]=" http://www.baidu.com/s?wd=%BB%BB%CD%BC%B4%FA%C2%EB&lm=0&si=&rn=10&tn=sitehao123&ie=gb2312&ct=0&cl=3&f=1&rsp=4";
var preloadedimages=new Array();
for (i=1;i<bannerAD.length;i++){
preloadedimages[i]=new Image();
preloadedimages[i].src=bannerAD[i];
}
function setTransition(){
if (document.all){
bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);
bannerADrotator.filters.revealTrans.apply();
}
}
function playTransition(){
if (document.all)
bannerADrotator.filters.revealTrans.play()
}
function nextAd(){
if(adNum<bannerAD.length-1)adNum++ ;
else adNum=0;
setTransition();
document.images.bannerADrotator.src=bannerAD[adNum];
playTransition();
theTimer=setTimeout("nextAd()", 5000);
}
function jump2url(){
jumpUrl=bannerADlink[adNum];
jumpTarget='_blank';
if (jumpUrl != ''){
if (jumpTarget != '')window.open(jumpUrl,jumpTarget);
else location.href=jumpUrl;
}
}
function displayStatusMsg() {
status=bannerADlink[adNum];
document.returnValue = true;
}
//-->
</SCRIPT> <A href="javascript:jump2url()" onmouseover="displayStatusMsg();return document.returnValue"><IMG border=0 width="380" name=bannerADrotator src="load_pic2666.jpg" ></A>
<SCRIPT language=JavaScript>nextAd()</SCRIPT>
- 2楼网友:思契十里
- 2021-04-20 11:25
<!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 n=0;
function img1(){
if(n==0)
{
document.getElementById("imgflash").src="image/flower.jpg";
document.getElementById("imgflash").title="2";
}
if(n==1)
{
document.getElementById("imgflash").src="image/flower2.jpg";
document.getElementById("imgflash").title="3";
}
if(n==2)
{
document.getElementById("imgflash").src="image/s1.jpg";
document.getElementById("imgflash").title="4";
}
if(n==3)
{
document.getElementById("imgflash").src="image/s2.jpg";
document.getElementById("imgflash").title="1";
}
n=n+1;
n=n%4;
}
window.setInterval("img1()", 3000);
</script>
</head>
<body>
<form name="myform">
<input type="image" name="imgflash">
</form>
</body>
</html>
- 3楼网友:渡鹤影
- 2021-04-20 10:10
<!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 n=0;
function img1(){
if(n==0){
myform.imgflash.src="image/flower.jpg";
}
if(n==1){
myform.imgflash.src="image/flower2.jpg";
}
if(n==2){
myform.imgflash.src="image/s1.jpg";
}
if(n==3){
myform.imgflash.src="image/s2.jpg";
}
n=n+1;
n=n%4;
}
window.setInterval("img1()", 3000);
</script>
</head>
<body>
<form name="myform">
<input type="image" name="imgflash">
</form>
</body>
</html>
我要举报
大家都在看
推荐资讯