Code for Implementing Image scrolling by js + div

Source: Internet
Author: User

Horizontal
<Div id = demo style = "overflow: hidden; width: 200px; border: 2px solid # e0e0e0; padding: 2px;" onmouseover = "stopscroll ();"

Onmouseout = "doscroll ()">
<Div id = "demo1" style = "white-space: nowrap; padding: 0;">
<A href = "javascript: alert ('Post new paint');">

Border = 0> </a>
<A href = "javascript: alert ('Post response');">

Border = 0> </a>
</Div>
</Div>
<! -- Rolling javascript -->
<Script>
Var t = demo. scrollWidth
Demo1.innerHTML + = demo1.innerHTML
Function doMarquee ()
{
Demo. scrollLeft = demo. Scrolling left <demo. scrollWidth-demo.offsetWidth? Demo. scrollLeft + 1: t-demo.offsetWidth
}
Function doscroll ()
{
SC = setInterval (doMarquee, 20)
}
Function stopscroll ()
{
ClearInterval (SC)
}
Doscroll ()
</Script>
<! -- Rolling javascript ends -->


Vertical
<Div id = "demo" style = "height: 110px; overflow: hidden">
<Div id = "demo1">
<A href = "javascript: alert ('Post new paint');">

Border = 0> </a>
<A href = "javascript: alert ('Post response');">

Border = 0> </a>
</Div> <div id = "demo2"> </div>
<! -- Rolling javascript -->
<Script>
Var speed = 100
Demo2.innerHTML = demo1.innerHTML
Function Marquees (){
If (demo2.offsetTop-demo. scrollTop <= 0)
Demo. scrollTop-= demo1.offsetHeight
Else {
Demo. scrollTop ++
}
}
Var MyMars = setInterval (Marquees, speed)
Demo. onmouseover = function () {clearInterval (MyMars )}
Demo. onmouseout = function () {MyMars = setInterval (Marquees, speed )}
Zlselect ('6 ');
</Script> <! -- Rolling javascript ends -->
</Div>

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.