js 橫向不間斷的圖片滾動效果

來源:互聯網
上載者:User
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>橫向不間斷的圖片滾動效果</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--把下面代碼加到<head>與</head>之間-->
<style type="text/css教程">
#film{border:#39c 1px dashed;}
#film a{float:left;margin-right:3px;border:#ccc 3px solid;}
#film img{border:none;}
</style>
<script type="text/網頁特效">
function na(){
 this.shw={
  id:0,imgs:"",links:"",atarget:"_blank",bgcolor:"#ffffff",width:0,height:0,imgwidth:"auto",imgheight:"auto",movespeed:0,$:function(id){return document.getelementbyid(id);},
  startmove:function(){
   if(this.id==0||this.width==0||this.height==0){alert("請檢查參數是否設定完全!");return "";}
   document.write("<div id="msg"></div><div style="float:left;overflow:hidden;width:"+this.width+"px;height:"+this.height+"px;overflow:hidden;" id=""+this.id+""><div style="float:left;width:800%;"><div style="float:left;" id="nanatemp"></div><div style="float:left;"  id="nanatemp2"></div></div></div>");
   var imgs=this.imgs.split("@");
   for(var i=0;i<imgs.length;i++){
    this.$("nanatemp2").innerhtml+="<a href="#"><img style="width:"+this.imgwidth+"px;height:"+this.imgheight+"px" src=""+imgs[i]+"" /></a>";
   }
   var links=this.links.split("@"); 
   var fcount=(imgs.length>links.length)?links.length:imgs.length; 
   for(var i=0;i<fcount;i++){
    var o=this.$("nanatemp2").getelementsbytagname("a");
    o[i].href=links[i];
    o[i].target=this.atarget;
   }
   var d1=this.$(this.id);
   var d2=this.$("nanatemp");
   var d3=this.$("nanatemp2");
   var speed=this.movespeed;
   function moves(){
    d2.innerhtml=d3.innerhtml;
    if(d3.offsetwidth-d1.scrollleft<=0){
     d1.scrollleft=d1.scrollleft-d2.offsetwidth;
    }
    else{
     d1.scrollleft=d1.scrollleft+1; 
    }
   }
   var mymar=setinterval(moves,speed);
   d1.onmouseo教程ver=function() {clearinterval(mymar)};
   d1.onmouseout=function() {mymar=setinterval(moves,speed)}; 
  } 
 }
}
</script>
</head>
<body>
<!--把下面代碼加到<body>與</body>之間-->
<script type="text/javascript"> 
var myna=new na();
myna.shw.id="film";//必寫,為要產生的標籤指定一個id,這樣就方便在你的css樣式表中設定樣式
myna.shw.bgcolor="#000000";//可選 背景顏色
myna.shw.width=600;//必寫,產生的div的寬度
myna.shw.height=255;//必寫,產生的div的高度
//myna.shw.imgwidth=120;//可選,圖片的寬度
myna.shw.imgheight=250;//可選,圖片的高度
myna.shw.movespeed=10;//必選,移動速度,建議使用這個速度
myna.shw.imgs="/effect/images/201009182345/20099131146339.jpg@/effect/images/201009182345/20099131146264.jpg@/effect/images/201009182345/20099131146966.jpg@/effect/images/201009182345/20099131146422.jpg@/effect/images/201009182345/tpic_921e5a51512b3e8fdde250eddef02b23.jpg";//圖片地址,多張圖片以@號隔開
myna.shw.links="@@@@";//圖片的連結地址,多個地址以@號隔開
myna.shw.startmove();//啟動播放
</script>
</body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.