JS horizontal continuous picture scrolling effect

Source: Internet
Author: User
Tags setinterval
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<title> Horizontal Continuous picture scrolling effect </title>
<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >
<!--Add the following code to <style type= "Text/css Tutorial" >
#film {border: #39c 1px dashed;}
#film A{float:left;margin-right:3px;border: #ccc 3px solid;}
#film Img{border:none;}
</style>
<script type= "text/web Effects" >
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 ("Please check that the parameters are set completely!") "); 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;ithis.$ ("Nanatemp2"). innerhtml+= "<a href=" # "></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 Tutorial Ver=function () {clearinterval (MyMar)};
D1.onmouseout=function () {Mymar=setinterval (moves,speed)};
}
}
}
</script>
<body>
<!--Add the following code to <body> and </body>-->
<script type= "Text/javascript" >
var myna=new na ();
Myna.shw.id= "film" or "write", specify an ID for the label to be generated, so you can easily set the style in your CSS style sheet
Myna.shw.bgcolor= "#000000";/optional background color
myna.shw.width=600;//write, the width of the div generated
myna.shw.height=255;//will write, the height of the div generated
myna.shw.imgwidth=120;//Optional, width of the picture
myna.shw.imgheight=250;//optional, height of the picture
myna.shw.movespeed=10;//required, moving speed, recommended to use this speed
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 "//Picture address, multiple pictures separated by @ number
Myna.shw.links= "";//the link address of the picture, with multiple addresses separated by the @ number
Myna.shw.startmove ()//Start playback
</script>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.