JavaScript to achieve a simple picture scrolling with source download _javascript tips

Source: Internet
Author: User
Did you see the war of focus between Germany and Portugal last night? In the early hours of the Beijing game, Ronaldo led the Portuguese 0-4 Germany was finished ... He is the Golden Globe winner, the European boot, the Champions League champions, the Portuguese team ... 9 Images Ronaldo tells you what it is to cry without tears
Copy Code code as follows:

<span style= "FONT-SIZE:14PX;" ><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>scroll image</title>
<meta http-equiv= "Content-type" content= "Text/html;charset=utf-8" >
<style type= "Text/css" >
Body
{
font-size:12px;
Font-family: "Microsoft Yahei", ' Microsoft James Black ', ' SimSun ', ' XXFarEastFont-Arial ';
margin:0px;
padding:0px;
Text-align:center;
}
Img
{
width:150px;
height:150px;
}
. news_root
{
width:225px;
height:134px;
Text-align:left;
margin:0 Auto;
}
Div. news_header
{
width:243px;
height:16px;
Vertical-align:top;
Text-align:left;
font-size:14px;
padding:6px;
}
#scrollContainer
{
width:345px;
MARGIN:2PX 5px;
Overflow:hidden;
Text-align:left;
}
</style>
<body>
<div class= "News_root" >
<div class= "News_header" >c Luo don't Cry, come on </div>
<div id= "Scrollcontainer" >
<div id= "Scrollcontent" >
<table border= "0" >
<tr align= "Middle" >
&LT;TD id= "Firstcol" >
<table border= "0" >
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</td>
&LT;TD id= "Lastcol" ></td>
</tr>
</table>
</div>
</div>
</div>
<script type= "Text/javascript" >
var stopscroll = false;
var scrollcontheight = 155;
var scrollcontwidth = 300;
var scrollspeed = 25;

var scrollcontainer = document.getElementById (' Scrollcontainer ');
var scrollcontent = document.getElementById (' scrollcontent ');
var firstcol = document.getElementById (' Firstcol ');
var lastcol = document.getElementById (' lastcol ');

Copy the contents of the first column to the second column, allowing scrolling to appear contiguous
lastcol.innerhtml = firstcol.innerhtml;
ScrollContainer.style.width = scrollcontwidth+ "px";
ScrollContainer.style.height = scrollcontheight+ "px";
Scrollcontainer.nowrap = true;
Scrollcontainer.onmouseover = new Function ("stopscroll=true;");
Scrollcontainer.onmouseout = new Function ("stopscroll=false;");

function init ()
{
Scrollcontainer.scrollleft = 0;
SetInterval (Scrollleft1,scrollspeed);
}
Init ();
var currleft = 0;
function ScrollLeft1 ()
{
if (Stopscroll = = true) return;
Currleft = Scrollcontainer.scrollleft;
Scrollcontainer.scrollleft + 1;
if (Currleft = = Scrollcontainer.scrollleft)
{
Scrollcontainer.scrollleft = 0;
Scrollcontainer.scrollleft + 1;
}
}
</script>
</body>

SOURCE download
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.