日期:2014-05-16 浏览次数:20410 次
<!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"> <div id="div1"> <table border='0' width='330px' cellspacing='0' cellpadding='0'> <tr><td style='height:20px;'>111111</td></tr> <tr><td style='height:20px;'>222222</td></tr> <tr><td style='height:20px;'>333333</td></tr> </table> </div> <div id="temp1" style="visibility: hidden"> </div> <script type="text/javascript" language="javascript"> //<![CDATA[ var diva = document.getElementById("div1"); var tema = document.getElementById("temp1"); var xx_a = 0; var marqueesHeight = 100; //内容区高度 var stop_a = false; //这个变量控制是否停止滚动 var preTop_a = 0; //这个变量用于判断滚动条是否已经到了尽头 diva.noWrap = true; //这句表内容区不自动换行 diva.style.width = 0 + "px"; //于是我们可以将它的宽度设为0,因为它会被撑大 diva.style.height = marqueesHeight + "px"; diva.style.overflowY = "hidden"; //滚动条不可见 diva.onmouseover = function(){stop_a=true;}; //鼠标经过,停止滚动 diva.onmouseout = function(){stop_a=false;}; //鼠标离开,开始滚动 document.body.onload = init; function init(){ //初始化滚动内容 while(parseInt(tema.offsetHeight) < parseInt(marqueesHeight)){ tema.innerHTML += diva.innerHTML; } diva.innerHTML = tema.innerHTML + tema.innerHTML; setTimeout(scrollUpa2,1000); } function scrollUpa2(){ setInterval(scrollUpa,2000); } function scrollUpa(){ //滚动条的驱动函数 if(xx_a == 20) { xx_a = 0; return; } if(stop_a == true) return; //如果变量"stopscroll"为真,则停止滚动 preTop_a = parseInt(diva.scrollTop); //记录滚动前的滚动条位置 diva.scrollTop += 1; //滚动条向下移动一个像素 //如果滚动条不动了,则向上滚动到和当前画面一样的位置 //当然不仅如此,同样还要向下滚动一个像素(+1): if(preTop_a == parseInt(diva.scrollTop)){ diva.scrollTop = tema.offsetHeight - marqueesHeight + 1; } xx_a += 1; setTimeout(scrollUpa,10); } //]]> </script> </html>
<!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> </head> <body> <div id="div1"> <table border='0' width='330px' cellspacing='0' cellpadding='0'> <tr><td style='height:20px;'>111111</td></tr> <tr><td style='height:20px;'>222222</td></tr> <tr><td style='height:20px;'>333333</td></tr> </table> </div> <div id="temp1" style="visibility: hidden"> </div> </body> </html> <script type="text/javascript" language="javascript"> //<![CDATA[ var diva = document.getElementById("div1"); var tema = document.getElementById("temp1"); var xx_a = 0; var marqueesHeight = 100; //内容区高度 var stop_a = false; //这个变量控制是否停止滚动 var preTop_a = 0; //这个变量用于判断滚动条是否已经到了尽头 diva.noWrap = true; //这句表内容区不自动换行 diva.style.width = 0 + "px"; //于是我们可以将它的宽度设为0,因为它会被撑大 diva.style.height = marqueesHeight + "px"; diva.style.ov