232934jzucgc8n7t4447i4.png (496.77 KB, 下载次数: 30)
<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>test</title> <style type="text/css"> #textHeight{line-height:25px; height:25px; overflow:hidden; width:150px; font-size:12px; border:solid 1px #666;} </style> <script language="javascript" type="text/javascript"> function ScrollText(content){ this.Delay=10; this.Amount=1; this.Direction="up"; this.Timeout=1000; this.ScrollContent=this.gid(content); this.ScrollContent.innerHTML += this.ScrollContent.innerHTML; this.ScrollContent.onmouseover = this.GetFunction(this,"Stop"); this.ScrollContent.onmouseout = this.GetFunction(this,"Start"); } ScrollText.prototype.gid=function(element){ return document.getElementById(element); } ScrollText.prototype.Stop=function(){ clearTimeout(this.AutoScrollTimer); clearTimeout(this.ScrollTimer); } ScrollText.prototype.Start=function(){ clearTimeout(this.AutoScrollTimer); this.AutoScrollTimer=setTimeout(this.GetFunction(this,"AutoScroll"),this.Timeout); } ScrollText.prototype.AutoScroll=function(){ if(this.Direction=="up"){ if(parseInt(this.ScrollContent.scrollTop)>=parseInt(this.ScrollContent.scrollHeight)/2){ this.ScrollContent.scrollTop=0; clearTimeout(this.AutoScrollTimer); this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout); return; } this.ScrollContent.scrollTop += this.Amount; }else { if(parseInt(this.ScrollContent.scrollTop) <= 0) { this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2; } this.ScrollContent.scrollTop -= this.Amount; } if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) { this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Delay); } else { this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout); } } ScrollText.prototype.GetFunction=function(variable,method){ return function() { variable[method](); } } </script> </head> <body> <div id="textHeight" title="xx"> <a href="#">12345</a> <span> | </span> <a href="#">23456</a> <span> | </span> <a href="#">34567</a> <span> | </span> <a href="#">45678</a> <span> | </span> <a href="#">56789</a> <span> | </span> </div> <script> var scrollup = new ScrollText("textHeight"); scrollup.Start(); </script> </body> </html>
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |