当前位置:asp编程网>技术教程>Javascript教程>  正文

纯Javascript实现的幻灯片实例

2012-06-13 09:30:42   来源:www.aspbc.com    作者:wangsdong   浏览量:2800   收藏
这里介绍一个纯Javascript幻灯片实例
<a href= "#"  onclick= "jump2url(this); "> 
<img border="0"  width="334" height="186"  style= "FILTER: revealTrans(duration=2,transition=20)" src= "javascript:nextAd()" name= "imgInit" /> </a> 
<div style= "padding:3px;line-height:150% "> <a href="" onmouseover= "this.title=this.innerHTML" id= "Hter"> </a> </div> 

<script type="text/javascript"> 
var I = new Array(); 
var H = new Array(); 
var T = new Array(); 
var preloadedimages = new Array(); 
var adNum = 0; 


for (i=0;i < I.length;i++){ 
  preloadedimages[i]=new Image(); 
  preloadedimages[i].src=I[i]; 
} 

function setTransition(){ 
  if (document.all){ 
    imgInit.filters.revealTrans.Transition=Math.floor(Math.random()*23); 
    imgInit.filters.revealTrans.apply(); 
  } 
} 

function playTransition(){ 
  if (document.all) 
    imgInit.filters.revealTrans.play(); 
} 

function nextAd(){ 
  if(adNum < I.length-1) 
  adNum++ ; 
  else 
  adNum = 0; 
  setTransition(); 
  document.images.imgInit.src=I[adNum]; 
  document.images.imgInit.alt=T[adNum]; 
  document.images.imgInit.title=T[adNum]; 
  document.all.Hter.innerHTML=T[adNum]; 
  document.all.Hter.href=H[adNum]; 
  playTransition(); 
  theTimer = window.setTimeout( "nextAd() ",5000); 
} 

function jump2url(o){ 
  jumpUrl = H[adNum]; 
  jumpTarget = '_blank '; 
  if(jumpUrl != ' ') 
  { 
  o.target=jumpTarget; 
  o.href=jumpUrl;  
  } 
} 

I[0] = "http://www.aspbc.com/uploadfile/adv/s201251185558.jpg"; 
H[0] = "http://www.aspbc.com/code/showcode.asp?id=185";
T[0] = "绿色食品网站PSD模版"; 

I[1] = "http://www.aspbc.com/uploadfile/adv/s2012425164416.jpg"; 
H[1] = "http://www.aspbc.com/soft/showsoft.asp?id=181"; 
T[1] = "asp开发工具4.0"; 

I[2] = "http://www.aspbc.com/uploadfile/adv/s20111019140650.jpg"; 
H[2] = "http://www.aspbc.com/tech/showtech.asp?id=546"; 
T[2] = "VS2010三层架构实例显示某张表中"; 

nextAd() 
</script> 
(鼠标移到代码上去,在代码的顶部会出现四个图标,第一个是查看源代码,第二个是复制代码,第三个是打印代码,第四个是帮助)


关于我们-广告合作-联系我们-积分规则-网站地图

Copyright(C)2013-2017版权所属asp编程网