CSS:
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
#scrollWrap{width:450px;height:18px;overflow:hidden;}
#scrollMsg li{height:18px;line-height:18px;overflow:hidden;font-size:12px;padding:0 10px;}
</style>
html:
<div id="scrollWrap">
<ul id="scrollMsg">
<g:each in="${newes }" status="i" var="lab">
<li><a href="${request.getContextPath() }/news/show?id=${lab.id}">
${lab.newsTitle}
</a></li>
</g:each>
</ul>
</div>
js:
<script>
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>
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
#scrollWrap{width:450px;height:18px;overflow:hidden;}
#scrollMsg li{height:18px;line-height:18px;overflow:hidden;font-size:12px;padding:0 10px;}
</style>
html:
<div id="scrollWrap">
<ul id="scrollMsg">
<g:each in="${newes }" status="i" var="lab">
<li><a href="${request.getContextPath() }/news/show?id=${lab.id}">
${lab.newsTitle}
</a></li>
</g:each>
</ul>
</div>
js:
<script>
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>