JavaScript 图片滚动

[ 2004-09-09 00:43:57 | Author: zhenhua ]
Font Size: Large | Medium | Small
<div id="demo" style="overflow: hidden; width: 300px; height: 120px; background-color:#00cc66;">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
 <tr>
 <td id="demo1" nowrap="nowrap">
 <img src="http://image2.sina.com.cn/home/images/sina_logo2.gif" />
 <img src="http://image2.sina.com.cn/home/images/sina_logo2.gif" />
 <img src="http://image2.sina.com.cn/home/images/sina_logo2.gif" />
 <img src="http://image2.sina.com.cn/home/images/sina_logo2.gif" />
 <img src="http://image2.sina.com.cn/home/images/sina_logo2.gif" />
 </td>
 <td id="demo2" nowrap="nowrap"></td>
 </tr>
</tbody>
</table>
</div>
<script language="javascript">
var speed = 20
function Marquee()
{
if(demo2.offsetWidth-demo.scrollLeft<=0)
{
 demo.scrollLeft -= demo1.offsetWidth
}
else
{
 demo.scrollLeft ++
}

}

//demo.onmouseover = function(){clearInterval(MyMar)}
demo.onmouseout = function(){MyMar = setInterval(Marquee,speed)}

window.onload = function()
{
if(demo.offsetWidth < demo1.offsetWidth)
{
 demo2.innerHTML=demo1.innerHTML
 var MyMar=setInterval(Marquee,speed)
}
}
</SCRIPT>

Comments Feed Comments Feed: http://www.zhenhua.org/feed.asp?q=comment&id=166
UTF-8 Encoding Trackback URL: http://www.zhenhua.org/trackback.asp?id=166

View Mode: Show All | Comments: 1 | Trackbacks: 0 | Toggle Order | Views: 14039
1
Quote 陈波波
[ 2010-09-28 11:24:31 ]
好像鼠标放上去会变得更快的?
1

If you feel this site you find this information helpful, please click on the donation, which is voluntary,Thank you.
Post Comment
Smilies
[arrow] [biggrin] [confused] [cool]
[cry] [eek] [evil] [exclaim]
[frown] [idea] [lol] [mad]
[mrgreen] [neutral] [question] [razz]
[redface] [rolleyes] [sad] [smile]
[surprised] [twisted] [wink]
Enable UBB Codes
Auto Convert URL
Show Smilies
Hidden Comment
Username:   Password:   Register Now?
Security Code * Please Enter the Security Code