使用javascript进行连续滚动
continueous scrolling using javascript
<html>
<style type="text/css">
#news
{
position: relative;
box-shadow: 1px 4px 5px #aaa;
text-align: left;
padding: 5px;
line-height: 20px;
height: 235px;
background: white;
border: 1px solid #ccc;
border-radius: 15px;
background: #eee;
width: 280px;
float: right;
height: 250px;
overflow: hidden;
background-repeat: repeat;
padding: 3px;
border-radius: 15px;
}
</style>
<script type="text/javascript">
var delayTime=8
var marqueeSpeed=2
var pauseTime=1
var copySpeed=marqueeSpeed
var pauseSpeed=(pauseTime==0)? copySpeed: 0
var actualHeight=''
function ScrollMarquee()
{
if (parseInt(crossMarquee.style.top)>((actualHeight / 2)*(-1)+8))
crossMarquee.style.top=parseInt(crossMarquee.style.top)-copySpeed+"px"
else
crossMarquee.style.top=parseInt((marqueeheight - (actualHeight / 2)) / 2)+8 +"px"
}
function InitializeMarquee()
{
crossMarquee=document.getElementById("vmarquee")
crossMarquee.style.top=0
marqueeheight=document.getElementById("news").offsetHeight
actualHeight=crossMarquee.offsetHeight;
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1)
{
crossMarquee.style.height=marqueeheight+"px"
crossMarquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("ScrollMarquee()",30)', delayTime)
}
if (window.addEventListener)
window.addEventListener("load", InitializeMarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", InitializeMarquee)
else if (document.getElementById)
window.onload=InitializeMarquee
</script>
<div id="news" onMouseover="copySpeed=pauseSpeed" onMouseout="copySpeed=marqueeSpeed">
<div id="vmarquee" style="position: absolute; width: 98%;">
<div id="copy1">
<div>h</div><br>
<div>he</div><br>
<div>hel</div><br>
<div>hell</div><br>
<div>hello</div><br>
</div>
<div id="copy2" >
<div>h</div><br>
<div>he</div><br>
<div>hel</div><br>
<div>hell</div><br>
<div>hello</div><br>
</div>
</div>
</div>
<div id="news" onMouseover="copySpeed=pauseSpeed" onMouseout="copySpeed=marqueeSpeed">
<div id="vmarquee" style="position: absolute; width: 98%;">
<div id="copy1">
<div>h</div><br>
<div>he</div><br>
<div>hel</div><br>
<div>hell</div><br>
<div>hello</div><br>
</div>
<div id="copy2" >
<div>h</div><br>
<div>he</div><br>
<div>hel</div><br>
<div>hell</div><br>
<div>hello</div><br>
</div>
</div>
</div>
</html>
我使用了字幕标签来连续滚动,但它不起作用。然后我使用javascript进行连续滚动,它只适用于1个div。脚本仅针对1个div运行。我更改了另一个div id并保存脚本在另一个js文件名中,但它不起作用,请帮助我完成
Marquee在大多数现代浏览器的最新版本中都有所贬值。看看这个指南,在CSS中做字幕真的很容易:http://www.hongkiat.com/blog/css-marquee/.
相关文章:
- 如何做javascript连续滚动-自动加载
- 整页.js使用连续滚动或循环时禁用 moveSectionUp
- jQuery悬停时无限/连续滚动
- 不连续滚动-检测用户是否停止滚动
- 连续滚动背景
- 在 iOS Chrome 中获取连续滚动事件
- 连续的 html 页面滚动
- 连续滚动.AJAX, PHP, JAVASCRIPT, MYSQL.
- Twitter Bootstrap Carousel - 如何实现连续慢速滚动
- 连续图像垂直滚动条
- 使用javascript进行连续滚动
- 使用jquery在同一方向上连续滚动滑块
- 脚本连续滚动到页面底部
- 使用javascript的连续滚动页面
- 自定义按钮,以取代浏览器滚动-保持和连续滚动
- 连续滚动计时器-避免跳跃
- Jquery插件与连续滚动像新闻票
- 在HTML / Bootstrap中连续滚动图像
- 使用 jquery 航点连续滚动
- 帮助修改我的自定义JQuery滑块,以允许连续滚动