主题:  请问function在网页中起着什么作用?

5dyoyo

职务:普通成员
等级:1
金币:0.0
发贴:10
#12006/4/30 17:32:29
一段代码
<script language=javascript>
function changelimage()
{
document.form1.img1.src="images/01.gif"
}
</script>
问一下,function起着什么作用,另外想问一下,有什么办法可以让图片循环转换吗??



yiliaocheng

职务:普通成员
等级:2
金币:2.0
发贴:631
#22006/4/30 21:07:56
就是把表单中的img1的地址赋值为images/01.gif。
我这里有个图片循环转换的代码:
<%tupian1="images/01.gif"
tupian2="images/02.gif"
tupian3="images/03.gif"
tupian4="images/04.gif"
tupian5="images/05.gif"
tupian6="images/06.gif"
tupian1url="index.asp"
tupian2url="index.asp"
tupian3url="index.asp"
tupian4url="index.asp"
tupian5url="index.asp"
tupian6url="index.asp"%>
<script language=javascript>
var imgUrl=new Array();
var imgLink=new Array();
var adNum=0;

imgLink[2]="<%=tupian2url%>";
imgLink[1]="<%=tupian1url%>";
imgLink[3]="<%=tupian3url%>";
imgLink[4]="<%=tupian4url%>";

imgUrl[2]="<%=tupian2%>";
imgUrl[1]="<%=tupian1%>";
imgUrl[3]="<%=tupian3%>";
imgUrl[4]="<%=tupian4%>";

var imgPre=new Array();
var j=0;
for (i=0;i<=3;i++) {
    if(imgLink[i]!="" {j++;}
    else {break;}
}
function playTran(){
    if (document.all)
        imgInit.filters.revealTrans.play();
}

var key=0;
function nextAd(){
    if(adNum<j)adNum++ ;
    else adNum=1;
    
    if( key==0 ){key=1;}
    else if (document.all){
        imgInit.filters.revealTrans.Transition=25;
        imgInit.filters.revealTrans.apply();
playTran();

    }
    document.images.imgInit.src=imgUrl[adNum];
    jumpUrl=imgLink[adNum];
    theTimer=setTimeout("nextAd()", 5200);
}
function goUrl(){    
    jumpTarget='_blank';
    if (jumpUrl != ''){
        if (jumpTarget != '') window.open(jumpUrl,jumpTarget);
        else location.href=jumpUrl;
    }
}
</script>
<a href="javascript:goUrl()"><img style="FILTER: revealTrans(duration=2,transition=6)" src="javascript:nextAd()" width=300 border=0 name=imgInit height="200"></a>