Note: When you scroll up or down, the content height in cell demo1 must be greater than the height set in demo to scroll infinitely.
When you scroll left or right, the content width in the cell demo1 must be greater than the width set in the demo to scroll infinitely.
I. Scroll up and down
1. displayed content
Code
<Div id = "demo" style = "OVERFLOW: hidden; WIDTH: 200px; HEIGHT: 100px;">
<Table border = "0" cellpadding = "0" cellspacing = "0">
<Tr>
<Td id = "demo1"> <table width = "100%" height = "99" border = "0" cellpadding = "0" cellspacing = "0">
<Tr>
<Td> 1 </td>
</Tr>
<Tr>
<Td> 2 </td>
</Tr>
<Tr>
<Td> 3 </td>
</Tr>
</Table> </td>
</Tr>
<Tr>
<Td id = "demo2"> </td>
</Tr>
</Table>
</Div>
2. Scroll up JS
Code
<SCRIPT>
Var speed = 30
Var MyMarh = setInterval (Marqueeh, speed)
Demo2.innerHTML = demo1.innerHTML
// The principle is to constantly enter demoh1 content in demoh2, and then clear invisible content
// Use a table with two rows and one column. Put another table with content loaded in the previous column, which is defined as demoh1. The next column is an empty TD and is defined as demoh2.
// SPEED is used to control the SPEED.
Demo. onmouseover = function () {clearInterval (MyMarh )}
Demo. onmouseout = function () {MyMarh = setInterval (Marqueeh, speed )}
Function Marqueeh (){
If (demo2.offsetHeight-demo. scrollTop <= 0)
Demo. scrollTop-= demo1.offsetHeight
Else {
Demo. scrollTop ++
}
}
</SCRIPT>
3. Scroll down JS
Code
<Script>
Var speed = 30
Demo2.innerHTML = demo1.innerHTML
Demo. scrollTop = demo. scrollHeight
Var MyMar = setInterval (Marquee, speed)
Demo. onmouseover = function () {clearInterval (MyMar )}
Demo. onmouseout = function () {MyMar = setInterval (Marquee, speed )}
Function Marquee (){
If (demo1.offsetTop-demo. scrollTop> = 0)
Demo. scrollTop + = demo2.offsetHeight
Else {
Demo. scrollTop --
}
}
</Script>
2. Scroll left and right
1. display content
Code
<Div id = "demo" style = "overflow: hidden; height: 100px; width: 200px;">
<Table cellpadding = "0" cellspace = "0" border = "0">
<Tr>
<Td id = "demo1"> <table width = "200" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<Td> 1 </td>
<Td> 2 </td>
<Td> 3 </td>
</Tr>
</Table> </td>
<Td id = "demo2"> </td>
</Tr>
</Table>
</Div>
2. scroll to the left of JS
Code
<Script>
Var speed = 30
Var MyMar = setInterval (Marquee, speed)
Demo2.innerHTML = demo1.innerHTML
Demo. onmouseover = function () {clearInterval (MyMar )}
Demo. onmouseout = function () {MyMar = setInterval (Marquee, speed )}
Function Marquee (){
If (demo2.offsetWidth-demo. scrollLeft <= 0)
Demo. scrollLeft-= demo1.offsetWidth
Else {
Demo. scrollLeft ++
}
}
</Script>
3. Scroll JS to the right
Code
<Script>
Var speed = 30
Var MyMar = setInterval (Marquee, speed)
Demo2.innerHTML = demo1.innerHTML
Demo. onmouseover = function () {clearInterval (MyMar )}
Demo. onmouseout = function () {MyMar = setInterval (Marquee, speed )}
Function Marquee (){
If (demo. scrollLeft <= 0)
Demo. scrollLeft + = demo2.offsetWidth
Else {
Demo. scrollLeft --
}
}
</Script>
Very good network disk (http://ww618.com/-wangwang618 wish you every day, every day .))