比較的に使いやすいjs文字はシームレスにスクロールして、ff ie 678をサポートします.
15502 ワード
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title> </title>
- <style type="text/css">
- *{padding:0; margin:0;}
- #roll{ border:1px solid red;height:400px; margin:10px auto; width:350px; overflow:hidden;list-style:none;}
- #roll li{height:30px; padding-left:10px;line-height:30px; border-bottom:1px solid #ddd;}
- a{font-size:12px; text-decoration:none; font-family:' ';}
- </style>
- </head>
- <body>
- <ol id="roll">
- <li><a href="#"> </a></li>
- <li><a href="#"> </a></li>
- <li><a href="#"> </a></li>
- <li><a href="#"> </a></li>
- <li><a href="#"> </a></li>
- <li><a href="#"> </a></li>
- <li><a href="#"> </a></li>
- </ol>
- <div id="bug"></div>
- </body>
- <script type="text/javascript">
- (function(A){
- function _ROLL(obj){
- this.ele = document.getElementById(obj);
- this.interval = false;
- this.currentNode = 0;
- this.passNode = 0;
- this.speed = 100;
- this.childs = _childs(this.ele);
- this.childHeight = parseInt(_style(this.childs[0])['height']);
- addEvent(this.ele,'mouseover',function(){
- window._loveYR.pause();
- });
- addEvent(this.ele,'mouseout',function(){
- window._loveYR.start(_loveYR.speed);
- });
- }
- function _style(obj){
- return obj.currentStyle || document.defaultView.getComputedStyle(obj,null);
- }
- function _childs(obj){
- var childs = [];
- for(var i=0;i<obj.childNodes.length;i++){
- var _this = obj.childNodes[i];
- if(_this.nodeType===1){
- childs.push(_this);
- }
- }
- return childs;
- }
- function addEvent(elem,evt,func){
- if(-[1,]){
- elem.addEventListener(evt,func,false);
- }else{
- elem.attachEvent('on'+evt,func);
- };
- }
- function innerest(elem){
- var c = elem;
- while(c.childNodes.item(0).nodeType==1){
- cc = c.childNodes.item(0);
- }
- return c;
- }
- _ROLL.prototype = {
- start:function(s){
- var _this = this;
- _this.speed = s || 100;
- _this.interval = setInterval(function(){
- _this.ele.scrollTop += 1;
- _this.passNode++;
- if(_this.passNode%_this.childHeight==0){
- var o = _this.childs[_this.currentNode] || _this.childs[0];
- _this.currentNode<(_this.childs.length-1)?_this.currentNode++:_this.currentNode=0;
- _this.passNode = 0;
- _this.ele.scrollTop = 0;
- _this.ele.appendChild(o);
- }
- },_this.speed);
- },
- pause:function(){
- var _this = this;
- clearInterval(_this.interval);
- }
- }
- A.marqueen = function(obj){A._loveYR = new _ROLL(obj); return A._loveYR;}
- })(window);
- marqueen('roll').start(10/* 100*/);
- </script>
- </html>