JavaScript enables uninterrupted continuous scrolling of pictures

Source: Internet
Author: User
Tags setinterval
Javascript

The code produced does not give everyone comment! The picture in the code everyone can add their own super connection, the modified method is: <a href= "connected address" target=_blank></a>

First make the effect of scrolling up:

<!--point to link picture url-->
<base href= "http://www.xrss.cn" >
<div Id=demo style=overflow:hidden;height:150;width:90;background: #214984; color: #ffffff >
<div id=demo1>
<!--definition picture-->





</div>
<div id=demo2></div>
</div>


<script>
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>

Make the effect of scrolling down:

Replace the red font JS portion of the above "make up scrolling effect" with the following:

<script>
var speed=30
Demo2.innerhtml=demo1.innerhtml
Demo.scrolltop=demo.scrollheight
function Marquee () {
if (demo1.offsettop-demo.scrolltop>=0)
Demo.scrolltop+=demo2.offsetheight
else{
demo.scrolltop--
}
}
var mymar=setinterval (Marquee,speed)
Demo.onmouseover=function () {clearinterval (MyMar)}
Demo.onmouseout=function () {Mymar=setinterval (marquee,speed)}
</script>

Make a left scroll effect:

<base href= "http://www.xrss.cn"
<div id=demo Style=overflow:hidden;height:33;width:200;background : #214984; color: #ffffff
<table align=left cellpadding=0 cellspace=0 border=0>
<tr>
<td Id=demo1 valign=top> </td>
<td id=demo2 valign=top></td>
</tr>
</table>
</div>

<script>
var speed=30
Demo2.innerhtml=demo1.innerhtml
function Marquee () {
if (demo2.offsetwidth-demo.scrollleft<=0)
Demo.scrollleft-=demo1.offsetwidth
else{
demo.scrollleft++
}
}
var mymar=setinterval (Marquee,speed)
Demo.onmouseover=function () {clearinterval (MyMar)}
Demo.onmouseout=function () {Mymar=setinterval (marquee,speed)}
</script>

Make the right scrolling effect:
Replace the red Font JS section in the "Make left scrolling effect" above:
<script>
var speed=30
Demo2.innerhtml=demo1.innerhtml
Demo.scrollleft=demo.scrollwidth
function Marquee () {
if (demo.scrollleft<=0)
Demo.scrollleft+=demo2.offsetwidth
else{
demo.scrollleft--
}
}
var mymar=setinterval (Marquee,speed)
Demo.onmouseover=function () {clearinterval (MyMar)}
Demo.onmouseout=function () {Mymar=setinterval (marquee,speed)}
</script>



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.