这段html中的JS文字滚动代码,如何加入鼠标事件
这段html中的JS文字滚动代码,如何加入鼠标移动上面暂停,鼠标挪开继续滚动呢,谢谢!<styletype="text/css">#rollText{font:12px/...
这段html中的JS文字滚动代码,如何加入鼠标移动上面暂停,鼠标挪开继续滚动呢,谢谢!
<style type="text/css">
#rollText{font:12px /20px verdana;color:#ffffff;}
</style>
<div id="rollAD" style="height:40px; position:relative; overflow:hidden;">
<div id="rollText" style="font-size:12px; line-height:20px;">
<a href="/" title="">◇ 安理会改革拟新增七理事国1</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定2</a><br />
<a href="/" title="">◇ 安理会改革拟新增七理事国3</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定4</a><br />
<a href="/" title="">◇ 安理会改革拟新增七理事国5</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定6</a><br />
<a href="/" title="">◇ 安理会改革拟新增七理事国7</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定8</a><br />
</div>
</div>
<script type="text/javascript">
var textDiv = document.getElementById("rollText");
var textList = textDiv.getElementsByTagName("a");
if(textList.length > 2){
var textDat = textDiv.innerHTML;
var br = textDat.toLowerCase().indexOf("<br",textDat.toLowerCase().indexOf("<br")+3);
//var textUp2 = textDat.substr(0,br);
textDiv.innerHTML = textDat+textDat+textDat.substr(0,br);
textDiv.style.cssText = "position:absolute; top:0";
var textDatH = textDiv.offsetHeight;MaxRoll();
}
var minTime,maxTime,divTop,newTop=0;
function MinRoll(){
newTop++;
if(newTop<=divTop+40){
textDiv.style.top = "-" + newTop + "px";
}else{
clearInterval(minTime);
maxTime = setTimeout(MaxRoll,5000);
}
}
function MaxRoll(){
divTop = Math.abs(parseInt(textDiv.style.top));
if(divTop>=0 && divTop<textDatH-40){
minTime = setInterval(MinRoll,1);
}else{
textDiv.style.top = 0;divTop = 0;newTop=0;MaxRoll();
}
}
</script> 展开
<style type="text/css">
#rollText{font:12px /20px verdana;color:#ffffff;}
</style>
<div id="rollAD" style="height:40px; position:relative; overflow:hidden;">
<div id="rollText" style="font-size:12px; line-height:20px;">
<a href="/" title="">◇ 安理会改革拟新增七理事国1</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定2</a><br />
<a href="/" title="">◇ 安理会改革拟新增七理事国3</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定4</a><br />
<a href="/" title="">◇ 安理会改革拟新增七理事国5</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定6</a><br />
<a href="/" title="">◇ 安理会改革拟新增七理事国7</a><br />
<a href="/" title="">◇ 国务院领导工作分工确定8</a><br />
</div>
</div>
<script type="text/javascript">
var textDiv = document.getElementById("rollText");
var textList = textDiv.getElementsByTagName("a");
if(textList.length > 2){
var textDat = textDiv.innerHTML;
var br = textDat.toLowerCase().indexOf("<br",textDat.toLowerCase().indexOf("<br")+3);
//var textUp2 = textDat.substr(0,br);
textDiv.innerHTML = textDat+textDat+textDat.substr(0,br);
textDiv.style.cssText = "position:absolute; top:0";
var textDatH = textDiv.offsetHeight;MaxRoll();
}
var minTime,maxTime,divTop,newTop=0;
function MinRoll(){
newTop++;
if(newTop<=divTop+40){
textDiv.style.top = "-" + newTop + "px";
}else{
clearInterval(minTime);
maxTime = setTimeout(MaxRoll,5000);
}
}
function MaxRoll(){
divTop = Math.abs(parseInt(textDiv.style.top));
if(divTop>=0 && divTop<textDatH-40){
minTime = setInterval(MinRoll,1);
}else{
textDiv.style.top = 0;divTop = 0;newTop=0;MaxRoll();
}
}
</script> 展开
展开全部
var textDiv = document.getElementById("rollText");
var textList = textDiv.getElementsByTagName("a");
if(textList.length > 2){
var textDat = textDiv.innerHTML;
var br = textDat.toLowerCase().indexOf("<br",textDat.toLowerCase().indexOf("<br")+3);
//var textUp2 = textDat.substr(0,br);
textDiv.innerHTML = textDat+textDat+textDat.substr(0,br);
textDiv.style.cssText = "position:absolute; top:0";
var textDatH = textDiv.offsetHeight;
MaxRoll();
textDiv.onmouseenter = function() {//鼠标进入
clearInterval(maxTime);
}
textDiv.onmouseleave = function() {//鼠标离开
MaxRoll();
}
}
var minTime,maxTime,divTop,newTop=0;
function MinRoll(){
newTop++;
if(newTop<=divTop+40){
textDiv.style.top = "-" + newTop + "px";
}else{
clearInterval(minTime);
maxTime = setTimeout(MaxRoll,5000);
}
}
function MaxRoll(){
divTop = Math.abs(parseInt(textDiv.style.top));
if(divTop>=0 && divTop<textDatH-40){
minTime = setInterval(MinRoll,1);
}else{
textDiv.style.top = 0;
divTop = 0;
newTop=0;
MaxRoll();
}
}
var textList = textDiv.getElementsByTagName("a");
if(textList.length > 2){
var textDat = textDiv.innerHTML;
var br = textDat.toLowerCase().indexOf("<br",textDat.toLowerCase().indexOf("<br")+3);
//var textUp2 = textDat.substr(0,br);
textDiv.innerHTML = textDat+textDat+textDat.substr(0,br);
textDiv.style.cssText = "position:absolute; top:0";
var textDatH = textDiv.offsetHeight;
MaxRoll();
textDiv.onmouseenter = function() {//鼠标进入
clearInterval(maxTime);
}
textDiv.onmouseleave = function() {//鼠标离开
MaxRoll();
}
}
var minTime,maxTime,divTop,newTop=0;
function MinRoll(){
newTop++;
if(newTop<=divTop+40){
textDiv.style.top = "-" + newTop + "px";
}else{
clearInterval(minTime);
maxTime = setTimeout(MaxRoll,5000);
}
}
function MaxRoll(){
divTop = Math.abs(parseInt(textDiv.style.top));
if(divTop>=0 && divTop<textDatH-40){
minTime = setInterval(MinRoll,1);
}else{
textDiv.style.top = 0;
divTop = 0;
newTop=0;
MaxRoll();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询