http://yule.sohu.com/s2005/dacj.shtml 右上角的大图片,自动循环刷新, 这种功能是怎么实现的? |
http://yule.sohu.com/s2005/dacj.shtml 右上角的大图片,自动循环刷新, 这种功能是怎么实现的? |
在<head>中加入<SCRIPT language=javascript> function imgsrcarray() //此处修改,可以加入多个数组,如imgsrc[1]等 { var imgsrcurl = new Array(); var imgsrc = new Array(); var imgalt = new Array(); imgsrc[0] = "图片地址"; imgsrcurl[0] = "链接页面"; imgalt[0] = "ALT提示";
loadpic(imgsrc,imgsrcurl,imgalt); } </SCRIPT> <SCRIPT language=JavaScript>
var PICSLIDEIMG=new Array(); var PICSLIDEIMGlink=new Array(); var imgalt = new Array();
var adNum=0; var cycle=4000; function loadpic(img,imglink,imgalter) { PICSLIDEIMG = img; PICSLIDEIMGlink = imglink; imgalt = imgalter;
var preloadedimages=new Array(); for (i=1;i<PICSLIDEIMG.length;i++){ preloadedimages[i]=new Image(); preloadedimages[i].src=PICSLIDEIMG[i]; } } function setTransition(){ if (document.all){ PICSLIDEIMGNAME.filters.revealTrans.Transition=Math.floor(Math.random()*23); PICSLIDEIMGNAME.filters.revealTrans.apply(); } }
function playTransition(){ if (document.all) PICSLIDEIMGNAME.filters.revealTrans.play() }
function nextIMG(){ imgsrcarray() if(adNum<PICSLIDEIMG.length-1)adNum++ ; else adNum=0; setTransition(); document.images.PICSLIDEIMGNAME.src=PICSLIDEIMG[adNum]; document.images.PICSLIDEIMGNAME.alt=imgalt[adNum];
playTransition(); theTimer=setTimeout("nextIMG()", cycle); }
function jump2url(){ jumpUrl=PICSLIDEIMGlink[adNum]; jumpTarget='_blank'; if (jumpUrl != ''){ if (jumpTarget != '')window.open(jumpUrl,jumpTarget); else location.href=jumpUrl; } } function displayStatusMsg() { status=PICSLIDEIMGlink[adNum];
}</SCRIPT> 然后把<A onmouseover=displayStatusMsg(); href="javascript:jump2url()"><IMG style="FILTER: revealTrans(duration=2,transition=20)" height=208 src="javascript:nextIMG()" width=375 border=0 name=PICSLIDEIMGNAME></A>防盗适当的位置
我是这样做的: <SCRIPT language=JavaScript> <!-- if (window.Event) document.captureEvents(Event.MOUSEUP); function nocontextmenu() { event.cancelBubble = true event.returnValue = false; return false; } function norightclick(e) { if (window.Event) { if (e.which == 2 || e.which == 3) return false; } else if (event.button == 2 || event.button == 3) { event.cancelBubble = true event.returnValue = false; return false; } } document.oncontextmenu = nocontextmenu; // for IE5+ document.onmousedown = norightclick; // for all others //--> </SCRIPT>
<SCRIPT language=JavaScript> <!-- // BannerAD
var bannerAD=new Array(); var bannerADlink=new Array(); var adNum=0;
bannerAD[0]="images/01.gif"; bannerADlink[0]="http://www.163.com";
bannerAD[1]="images/02.gif"; bannerADlink[1]="http://www.163.com";
bannerAD[2]="images/03.gif"; bannerADlink[2]="http://www.163.com";
bannerAD[3]="images/04.gif"; bannerADlink[3]="http://www.163.com";
bannerAD[4]="images/05.gif"; bannerADlink[4]="http://www.163.com";
bannerAD[5]="images/06.gif"; bannerADlink[5]="http://www.163.com";
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()", 3600); //时间为4分钟 }
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>