Code for continuous scrolling of images

Source: Internet
Author: User

<Div id = "Demo" style = "position: absolute; left: 0; overflow: hidden; width: 670px; color: # ffffff;">
<Table cellpadding = "0" cellspacing = "0" border = "0">
<Tr>
<TD id = "demo1" valign = "TOP" align = "center">
<Table cellpadding = "2" cellspacing = "0" border = "0">
<Tr align = "center">
<TD> </TD>
<TD> </TD>
</Tr>
</Table>
</TD>
<TD id = "demo2" valign = "TOP"> </TD>
</Tr>
</Table>
</Div>

<Script language = JavaScript>
VaR begin = 0; // start position
VaR end = 100; // end position
VaR flg = false;
VaR speed = 10 // The greater the speed, the slower the speed.
Demo2.innerhtml = demo1.innerhtml
Function marquee (){
If (begin> = end)
Flg = true;
Else if (begin <= 0)
Flg = false;
If (flg)
Begin --;
Else
Begin ++;
Demo. style. Left = begin;
}
VaR mymar = setinterval (marquee, speed)
Demo. onmouseover = function () {clearinterval (mymar )}
Demo. onmouseout = function () {mymar = setinterval (marquee, speed )}
</SCRIPT>

<Div id = 'Demo' style = 'overflow: hidden; Height: 100px; width: 200px; white-space: nowrap; '>
<Div id = 'demo1' style = 'display: inline; '>
<! -- The database operation code can be placed here. -->
<Span> <a href = "#"> </a> </span>
<Span> <a href = "#"> </a> </span>
<Span> <a href = "#"> </a> </span>
<Span> <a href = "#"> </a> </span>
<Span> <a href = "#"> </a> </span>
</Div>
<Div id = 'demo2' style = 'display: inline; '> </div>
</Div>
<Script language = "JavaScript">
<! --
VaR speed = 1; // The greater the value, the slower the speed.
Demo2.innerhtml = demo1.innerhtml;
Function marquee (){

// Move left
If (demo2.offsetwidth-demo. scrollleft <= 0)
Demo. scrollleft-= demo1.offsetwidth
Else {
Demo. scrollleft ++
}

// Shift right
// If (demo1.offsetwidth-demo. scrollleft> = 0)
// Demo. scrollleft + = demo2.offsetwidth
// Else {
// Demo. scrollleft --
//}

}
VaR mymar = setinterval (marquee, speed)
// You can control the mouse hover effect.
Demo. onmouseover = function () {clearinterval (mymar )}
Demo. onmouseout = function () {mymar = setinterval (marquee, speed )}
// -->
</SCRIPT>

<Table>
<Tr>
<TD align = middle>
<Div align = center> </div>
<Div id = demo style = "overflow: hidden; width: 160px; Height: 150px">
<Div id = demo1>
<Br/> <a href = "#" target = _ blank> </a>
<Br/> <a href = "#" target = _ blank> </a>
<Br/> <a href = "#" target = _ blank> </a> string 9
<Br/> <a href = "#" target = _ blank> </a>
<Br/> <a href = "#" target = _ blank> </a> </div>
<Div id = demo2> </div>
<SCRIPT>
VaR speed = 2
Demo2.innerhtml = demo1.innerhtml
Function marquee (){
If (demo2.offsettop-demo. scrolltop <= 0)
Demo. scrolltop-= demo1.offsetheight
Else {
Demo. scrolltop ++
}
}
VaR mymar = setinterval (marquee, speed)
Demo. onmouseover = function () {clearinterval (mymar )}
Demo. onmouseout = function () {mymar = setinterval (marquee, speed )}
</SCRIPT>
</TD>
</Tr>
</Table>

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.