目录

广播滚动效果

广播左右无间断滚动效果

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>JS特效文字左右无间断滚动</title>
	<style type="text/css" media="all">
	.d1{
		margin:10px auto;
		width:200px;
		background-color:#CCCCCC;
		height:20px;
		overflow:hidden;
		white-space:nowrap;
	}
	.d2{
		margin:0px auto;
		background-color:#FF9933;
	}
	.div2{
		width:auto;
		height:20px;
		font-size:12px;
	}
	</style>
	<script language="javascript" type="text/javascript">
		var s,s2,s3,timer;

		function init(){
			s=getid("div1");
			s2=getid("div2");
			s3=getid("div3");
			s3.innerHTML=s2.innerHTML;
			timer=setInterval(mar,30)
		}

		function mar(){
			if(s2.offsetWidth <= s.scrollLeft){
				s.scrollLeft -= s2.offsetWidth;
			}else{
				s.scrollLeft++;
			}
		}

		function getid(id){
			return document.getElementById(id);
		}
		window.onload=init;
	</script>
</head>
<body>
	<div class="d1" id="div1" onmouseover="clearInterval(timer)" onmouseout="timer=setInterval(mar,30)">
	    <span class="div2" id="div2">
	    	<a href="http://www.4936.cn/">第一段文字,第二段文字,</a>
	    	<a href="http://www.4936.cn/">第三段文字链接</a>,第四段文字,第五段文字,第六段文字,
	    </span>
	    <span id="div3" class="div2"></span>
	</div>
</body>
</html>
Loading Disqus comments...