javascript文件冲突
<script language=JavaScript>
var imgUrl=new Array();
var imgLink=new Array();
var adNum=0;
imgUrl[1]= "../images/562/200406301.jpg ";
imgLink[1]= "/default.asp ";
imgUrl[2]= "../images/562/200406302.jpg ";
imgLink[2]= "/default.asp ";
imgUrl[3]= "../images/562/200406303.jpg ";
imgLink[3]= "/default.asp ";
imgUrl[4]= "../images/562/200406304.jpg ";
imgLink[4]= "/default.asp ";
imgUrl[5]= "../images/562/200406305.jpg ";
imgLink[5]= "/default.asp ";
var imgPre=new Array();
var j=0;
for (i=1;i <=5;i++) {
if( (imgUrl[i]!= " ") && (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=6;
imgInit.filters.revealTrans.apply();
playTran();
}
document.images.imgInit.src=imgUrl[adNum];
theTimer=setTimeout( "nextAd() ", 5000);
}
function goUrl(){
jumpUrl=imgLink[adNum];
jumpTarget= '_self ';
if (jumpUrl != ' '){
if (jumpTarget != ' ')
window.open(jumpUrl,jumpTarget);
else
location.href=jumpUrl;
}
}
</script>
<a href= "javascript:goUrl() "> <div aligm=right> <img style= "FILTER: revealTrans(duration=2,transition=6);border-color:#000000;color:#000000 " src= "javascript:nextAd() " width=150 border=1 class=moviepic name=imgInit height= "200 "> </div> </a>
<!-- 动态图结束 -->
这段代码要应用到同一页面的多处,单独用在一处的时候可以正常显示,可是用在多处的时候却不能正常显示,图片路径不一样,高手帮我解决以下
------解决方案--------------------自己改改变量名不就可以了吗
------解决方案--------------------具体看下哪里的代码有一样的吧
------解决方案--------------------改成function再调用。
------解决方案--------------------写到一个js文件里面
var imgUrl=new Array();
var imgLink=new Array();
var adNum=0;
imgUrl[1]= "../images/562/200406301.jpg ";
imgLink[1]= "/default.asp ";
imgUrl[2]= "../images/562/200406302.jpg ";
imgLink[2]= "/default.asp ";
imgUrl[3]= "../images/562/200406303.jpg ";
imgLink[3]= "/default.asp ";
imgUrl[4]= "../images/562/200406304.jpg ";
imgLink[4]= "/default.asp ";
imgUrl[5]= "../images/562/200406305.jpg ";
imgLink[5]= "/default.asp ";
var imgPre=new Array();