間隙間歇滾動代碼
文章導讀:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>符合標準的間隙滾動代碼(兼容IE和FireFox) - 建站學-www.eweiw.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
body { padding: 30px; font-size: 12px;}
a { color: #000; text-decoration: none; }
a:hover { color: #F60; }
#scrollWrap {
width:300px;
height: 18px;
overflow: hidden;
background: #E6F6F6;
}
#scrollMsg {
float: left;
text-align: left;
padding:0 10px;
}
#scrollMsg ul {
margin:0;
padding:0;
}
#scrollMsg li {
line-height: 18px;
list-style:none;
}
-->
</style>
</head>
<body>
<div id="scrollWrap">
<div id="scrollMsg">
<ul>
<li><a href="#">1111111111111</a></li>
<li><a href="#">22222222222</a></li>
<li><a href="#">333333333333333</a></li>
</ul>
</div>
</div>
<script type="text/javascript">
<!--
try{
var isStoped = false;
var oScroll = document.getElementById("scrollWrap");
with(oScroll){
noWrap = true;
}
oScroll.onmouseover = new Function('isStoped = true');
oScroll.onmouseout = new Function('isStoped = false');
var preTop = 0;
var curTop = 0;
var stopTime = 0;
var oScrollMsg = document.getElementById("scrollMsg");
oScroll.appendChild(oScrollMsg.cloneNode(true));
init_srolltext();
}catch(e) {}
function init_srolltext(){
oScroll.scrollTop = 0;
setInterval('scrollUp()', 15);
}
function scrollUp(){
if(isStoped) return;
curTop += 1;
if(curTop == 19) {
stopTime += 1;
curTop -= 1;
if(stopTime == 180) {
curTop = 0;
stopTime = 0;
}
}else{
preTop = oScroll.scrollTop;
oScroll.scrollTop += 1;
if(preTop == oScroll.scrollTop){
oScroll.scrollTop = 0;
oScroll.scrollTop += 1;
}
}
}
//-->
</script>
<p> </p>
<p> </p>
<p> </p>
<p>更多網站制作教程盡在 <a target="_blank">建站學</a></p>
</body>
</html>