Js upstream and downstream code scrolling

Source: Internet
Author: User

<Base href = "http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
Up
<Div id = demo style = "overflow: hidden; width: 128px; height: 300px;">
<Div id = demo1>
<br> <br> <br>

</Div>
<Div id = demo2> </div>
</Div>
<Script language = "javascript">
Var speed = 30
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>

Down

<Div id = demo3 style = "overflow: hidden; width: 128px; Height: 300px;">
<Div id = demo4>
<br> <br> <br>
</Div>
<Div id = demo5> </div>
</Div>
<Script language = "JavaScript">
VaR speed = 30
Demo5.innerhtml = demo4.innerhtml
Demo3.scrolltop = demo3.scrollheight
Function marquee (){
If (demo3.scrolltop <= 0)
Demo3.scrolltop + = demo5.offsetheight
Else {
Demo3.scrolltop --
}
}
VaR mymar = setinterval (marquee, speed)
Demo3.onmouseover = function () {clearInterval (MyMar )}
Demo3.onmouseout = function () {MyMar = setInterval (Marquee, speed )}
</Script>

Left

<Div id = demo6 style = "overflow: hidden; height: 100px; width: 300px;"> <table align = left

Cellpadding = 0 cellspace = 0 border = 0> <tr> <td id = demo7 valign = top>

Src = "bxtt.gif"> </td> <td id = demo8 valign = top> </td> </tr> </table> </div>
<Script>
Var speed = 30
Demo8.innerHTML = demo7.innerHTML
Function Marquee (){
If (demo8.offsetWidth-demo6.scrollLeft <= 0)
Demo6.scrollLeft-= demo7.offsetWidth
Else {
Demo6.scrollLeft ++
}
}
Var MyMar = setInterval (Marquee, speed)
Demo6.onmouseover = function () {clearinterval (mymar )}
Demo6.onmouseout = function () {mymar = setinterval (marquee, speed )}
</SCRIPT>

Right

<Div id = demo9 style = "overflow: hidden; Height: 100px; width: 300px;"> <Table align = left

Cellpadding = 0 cellspace = 0 border = 0> <tr> <TD id = demo10 valign = top>

Src = "bxtt.gif"> </TD> <TD id = demo11 valign = top> </TD> </tr> </table> </div>
<SCRIPT>
VaR speed = 30
Demo11.innerhtml = demo10.innerhtml
Demo9.scrollleft = demo9.scrollwidth
Function marquee (){
If (demo9.scrollleft <= 0)
Demo9.scrollleft + = demo11.offsetwidth
Else {
Demo9.scrollleft --
}
}
Var MyMar = setInterval (Marquee, speed)
Demo9.onmouseover = function () {clearInterval (MyMar )}
Demo9.onmouseout = function () {MyMar = setInterval (Marquee, speed )}
</Script>

When you scroll between the left and right sides, you cannot define the code in the scroll area as div but use table, because it is difficult to define the left and right sides of the div. This is my summary. I wonder if this is the case. There is always a problem when I use div scrolling.

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.