今日,我在网上找了一段图片交替出现的特效,我把代码放在后缀为html页面中,能正常显示出效果.
但是,我把代码放在后缀aspx中,就不能正常显示出效果.
我是一个js新手,大家能帮我看看吗?
代码如下:
<script language=JavaScript>
var imgUrl=new Array();
var imgLink=new Array();
var adNum=0;
imgUrl[1]="http://my.lkjt.com/xsgs/images/shengteng.jpg";
imgLink[1]="http://my.lkjt.com/xsgs/xinwen/news.aspx";
imgUrl[2]="http://my.lkjt.com/xsgs/images/lhd/lkxw.gif";
imgLink[2]="http://my.lkjt.com/xsgs/xinwen/news.aspx";
imgUrl[3]="http://my.lkjt.com/xsgs/images/lhd/ky.jpg";
imgLink[3]="http://my.lkjt.com/xsgs/xinwen/news.aspx";
imgUrl[4]="http://my.lkjt.com/xsgs/images/lhd/jz.jpg";
imgLink[4]="http://my.lkjt.com/xsgs/xinwen/news.aspx";
var imgPre=new Array();
var j=0;
for (i=1;i<=4;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()", 3000);
}
function goUrl(){
jumpUrl=imgLink[adNum];
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=20);border-color:black;color:#000000" src="javascript:nextAd()" width=240 height=190 border=1 class=img01 name=imgInit></a>