How can I solve the problem of conflicting two image scrolling codes on a page?

Source: Internet
Author: User

Why can't the image flow show after I copy a second piece of code on the home page?
Copy codeThe Code is as follows:
<Div align = "center">
<Table style = "TABLE-LAYOUT: fixed; border-collapse: collapse "cellSpacing = 0 cellPadding = 0 width = 760 border = 1 height =" 150 "bordercolor =" #1989D7 ">
<Tr>
& Lt; td height = "150" & gt;
<Div id = demo style = "OVERFLOW: hidden; WIDTH: 100%; HEIGHT: 150px">
<Table cellPadding = 0 align = left border = 0 cellspace = "0">
<Tr>
<Td id = demo1 vAlign = top> <! -- $ Latest image $ --> </td>
<Td id = demo2 vAlign = top> </td>
</Tr>
</Table>
</Div>
<SCRIPT>
Var speed = 25
Demo2.innerHTML = demo1.innerHTML
Function Marquee1 (){
If (demo2.offsetWidth-demo. scrollLeft <= 0)
Demo. scrollLeft-= demo1.offsetWidth
Else {
Demo. scrollLeft ++
}
}
Var MyMar = setInterval (Marquee1, speed)
Demo. onmouseover = function () {clearInterval (MyMar )}
Demo. onmouseout = function () {MyMar = setInterval (Marquee1, speed )}
</SCRIPT>

The two codes are identical, so conflicts occur. Simply modify another piece of code. The red mark must be modified.
Try:
Copy codeThe Code is as follows:
<! -- The second paragraph starts rolling the code to the right -->
<Div id = gundong style = "OVERFLOW: hidden; WIDTH: 568px; HEIGHT: 126px">
<Table cellPadding = 0 align = left border = 0 cellspace = "0">
<Tr>
<Td id = gundong1 vAlign = top>
<! -- {$ GetPicPhoto (1,126, 0, true, false, false, 90, 20, 0, true, 20)} --> </td>
<Td id = gundong2 vAlign = top> </td>
</Tr>
</Table>
</Div>
<Script>
Var speed = 25
Gundong2.innerHTML = gundong1.innerHTML
Gundong. scrollLeft = gundong. scrollWidth
Function Marquee1 (){
If (gundong. scrollLeft <= 0)
Gundong. scrollLeft + = gundong2.offsetWidth
Else {
Gundong. scrollLeft --
}
}
Var MyMar1 = setInterval (Marquee1, speed)
Gundong. onmouseover = function () {clearInterval (MyMar1 )}
Gundong. onmouseout = function () {MyMar1 = setInterval (Marquee1, speed )}
</Script>
<! -- The second paragraph scroll to the right to end the code -->

Related Article

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.