Regular scrolling of Images Written in js

Source: Internet
Author: User

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> 17 k-Liu Qing-qian Ye-yi </title>
<Meta http-equiv = content-type content = "text/html; charset = UTF-8">
<Style>
Body, img, ol, ul {margin: 0; padding: 0 ;}
Li {list-style-type: none ;}
. Roll {display: inline-block; overflow: hidden; width: 702px ;}
. Roll. leftBotton ,. roll. rightBotton {display: inline; float: left; margin: 61px 0px 0px; overflow: hidden; width: 14px; cursor: pointer; height: 51px; background: # f00}
. Roll. RightBotton {display: inline; float: right; margin: 61px 0px; overflow: hidden; width: 14px; cursor: pointer; height: 51px}
. Roll. cont {padding-right: 0px; padding-left: 0px; float: left; padding-bottom: 6px; overflow: hidden; width: 660px; padding-top: 16px}
. Roll. ScrCont {width: 0000000px}
. Roll. Cont li {float: left; width: pixel; text-align: center}
. Roll. cont li img {border-right: #666666 1px solid; border-top: #666666 1px solid; display: block; background: # fff; margin: 0px auto; border-left: #666666 1px solid; border-bottom: #666666 1px solid; width: 123px}
. Roll. Cont li p {color: #505050; line-height: 30px}
. Roll. Cont A: link {color: #505050; text-decoration: none}
. Blk_05. Cont A: visited {color: #505050; text-decoration: none}
. Roll. Cont A: hover {color: # f00; text-decoration: none}
. Roll # List1 {float: left}
. Roll # List2 {float: left}
</Style>
</Head>
<Body>
<Div class = "roll">
<Div onmouseup = "ISL_StopUp ()" class = "LeftBotton" onmousedown = "ISL_GoUp ()" onmouseout = "ISL_StopUp ()"> </div>
<Div class = "Cont" id = "ISL_Cont">
<Div class = "ScrCont">
<Div id = "List1">
<! -- Image list begin -->
<Ul>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
</Ul>
<! -- Image list end -->
</Div>
<Div id = "List2"> </div>
</Div>
</Div>
<Div onmouseup = "ISL_StopDown ()" class = "RightBotton" onmousedown = "ISL_GoDown ()"
Id = "RightBotton" onmouseout = "ISL_StopDown ()"> </div>
<Script language = javascript type = text/javascript> <! -- // --> <! [CDATA [//> <! --
// Image scrolling list mengjia 070927
Var Speed = 10; // Speed (MS)
Var Space = 5; // move each time (px)
Var PageWidth = 131; // page flip width
Var fill =-5; // overall shift
Var MoveLock = false;
Var MoveTimeObj;
Var Comp = 0;
Var AutoPlayObj = null;
GetObj ("List2"). innerHTML = GetObj ("List1"). innerHTML;
GetObj ('isl _ cont'). scrollLeft = fill> = 0? Fill: GetObj ('list1'). scrollWidth-Math. abs (fill );
GetObj ("ISL_Cont"). onmouseover = function () {clearInterval (AutoPlayObj );}
GetObj ("ISL_Cont"). onmouseout = function () {AutoPlay ();}
AutoPlay ();
Function GetObj (objName) {if (document. getElementById) {return eval ('document. getElementById ("'+ objName +'") ')} else {return eval ('document. all. '+ objName )}}
Function AutoPlay () {// auto scroll
ClearInterval (AutoPlayObj );
AutoPlayObj = setInterval ('isl _ GoDown (); ISL_StopDown (); ', 5000); // Interval
}
Function ISL_GoUp () {// starts turning up
If (MoveLock) return;
ClearInterval (AutoPlayObj );
MoveLock = true;
MoveTimeObj = setInterval ('isl _ ScrUp (); ', Speed );
}
Function ISL_StopUp () {// turn up and stop
ClearInterval (MoveTimeObj );
If (GetObj ('isl _ cont'). scrollLeft-fill) % PageWidth! = 0 ){

Comp = fill-(GetObj ('isl _ cont'). scrollLeft % PageWidth );
CompScr ();
} Else {
MoveLock = false;
}
AutoPlay ();
}
Function ISL_ScrUp () {// flip action
If (GetObj ('isl _ cont '). scrollLeft <= 0) {GetObj ('isl _ cont '). scrollLeft = GetObj ('isl _ cont '). scrollLeft + GetObj ('list1 '). offsetWidth}
GetObj ('isl _ cont'). scrollLeft-= Space;
}

Function ISL_GoDown () {// flip down
ClearInterval (MoveTimeObj );
If (MoveLock) return;
ClearInterval (AutoPlayObj );
MoveLock = true;
ISL_ScrDown ();
MoveTimeObj = setInterval ('isl _ ScrDown () ', Speed );
}
Function ISL_StopDown () {// flip-down stop
ClearInterval (MoveTimeObj );
If (GetObj ('isl _ cont'). scrollLeft % PageWidth-(fill> = 0? Fill: fill + 1 )! = 0 ){
Comp = PageWidth-GetObj ('isl _ cont'). scrollLeft % PageWidth + fill;
CompScr ();
} Else {
MoveLock = false;
}
AutoPlay ();
}
Function ISL_ScrDown () {// flip action
If (GetObj ('isl _ cont '). scrollLeft> = GetObj ('list1 '). scrollWidth) {GetObj ('isl _ cont '). scrollLeft = GetObj ('isl _ cont '). scrollLeft-GetObj ('list1 '). scrollWidth ;}
GetObj ('isl _ cont'). scrollLeft + = Space;
}

Function CompScr (){
Var num;
If (Comp = 0) {MoveLock = false; return ;}
If (Comp <0) {// flip
If (Comp <-Space ){
Comp + = Space;
Num = Space;
} Else {
Num =-Comp;
Comp = 0;
}
GetObj ('isl _ cont'). scrollLeft-= num;
SetTimeout ('compscr () ', Speed );
} Else {// flip-down
If (Comp> Space ){
Comp-= Space;
Num = Space;
} Else {
Num = Comp;
Comp = 0;
}
GetObj ('isl _ cont'). scrollLeft + = num;
SetTimeout ('compscr () ', Speed );
}
}
// --> <!]> </Script> <! -- Left end --> </DIV>
</BODY> </HTML>

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.