<script type="text/javascript">
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd(){
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}
function rand(number){
return Math.ceil(rnd()*number)-1;
}
var pushName=["网页特效","在远方","特效观止","网页代码"];
var pushSrc=["images/push01.jpg","images/push02.jpg","images/push03.jpg","images/push04.jpg"];
var pushLink=["http://www.web-theme.net","http://www.help068.com","http://www.tools8.net","http://www.jspal.com"]
var pushShow="";
function showPushLink(num){
if(!num&&num!=0){
mainPushNum++;
if(mainPushNum>3) mainPushNum=0;
num=mainPushNum;
}
for(i=0;i<4;i++){
document.getElementById("linkPush"+i).className="";
}
document.getElementById("linkPush"+num).className="linkPushHere";
document.getElementById("pushImg").src=pushSrc[num];
document.getElementById("pushImgLink").href=pushLink[num];
document.getElementById("pushImg").alt=pushName[num];
}
//初始化
for(i=0;i<4;i++){
pushShow+='<a href="'+pushLink[i]+'" οnmοuseοver="showPushLink('+i+');clearInterval(rollId)" id="linkPush'+i+'" target="_blank">'+pushName[i]+'</a>';
}
document.getElementById("linkPush").innerHTML=pushShow;
var mainPushNum=rand(4);
document.getElementById("linkPush"+mainPushNum).className="linkPushHere";
document.getElementById("mainPush").innerHTML='<a href="'+pushLink[mainPushNum]+'" target="_blank" id="pushImgLink" οnmοuseοver="clearInterval(rollId)" οnmοuseοut="showAtTime()"><img src="'+pushSrc[mainPushNum]+'" name="pushImg" width="460" height="165" id="pushImg" alt="'+pushName[mainPushNum]+'" /></a>';
var rollId=setInterval("showPushLink()",2000); //设置间隔时间
function showAtTime(){
showPushLink();
rollId=setInterval("showPushLink()",2000); //设置间隔时间
}
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd(){
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
}
function rand(number){
return Math.ceil(rnd()*number)-1;
}
var pushName=["网页特效","在远方","特效观止","网页代码"];
var pushSrc=["images/push01.jpg","images/push02.jpg","images/push03.jpg","images/push04.jpg"];
var pushLink=["http://www.web-theme.net","http://www.help068.com","http://www.tools8.net","http://www.jspal.com"]
var pushShow="";
function showPushLink(num){
if(!num&&num!=0){
mainPushNum++;
if(mainPushNum>3) mainPushNum=0;
num=mainPushNum;
}
for(i=0;i<4;i++){
document.getElementById("linkPush"+i).className="";
}
document.getElementById("linkPush"+num).className="linkPushHere";
document.getElementById("pushImg").src=pushSrc[num];
document.getElementById("pushImgLink").href=pushLink[num];
document.getElementById("pushImg").alt=pushName[num];
}
//初始化
for(i=0;i<4;i++){
pushShow+='<a href="'+pushLink[i]+'" οnmοuseοver="showPushLink('+i+');clearInterval(rollId)" id="linkPush'+i+'" target="_blank">'+pushName[i]+'</a>';
}
document.getElementById("linkPush").innerHTML=pushShow;
var mainPushNum=rand(4);
document.getElementById("linkPush"+mainPushNum).className="linkPushHere";
document.getElementById("mainPush").innerHTML='<a href="'+pushLink[mainPushNum]+'" target="_blank" id="pushImgLink" οnmοuseοver="clearInterval(rollId)" οnmοuseοut="showAtTime()"><img src="'+pushSrc[mainPushNum]+'" name="pushImg" width="460" height="165" id="pushImg" alt="'+pushName[mainPushNum]+'" /></a>';
var rollId=setInterval("showPushLink()",2000); //设置间隔时间
function showAtTime(){
showPushLink();
rollId=setInterval("showPushLink()",2000); //设置间隔时间
}
</script>
实例:仿易趣、拍拍、taobao等站首页广告图片随机轮显切换效果