对联效果

<script language="javascript">
    var oCouplet = new Object(); 

    function Couplet(_top, _width, _height, _offset, _delay, _amount) {
        this.author = '51JS.COM-ZMM';
        this.version = 'Couplet 1.0';
        this.top = _top;
        this.width = _width;
        this.height = _height;
        this.offset = _offset;
        this.delay = _delay;
        this.amount = _amount;

        this.drawCouplet = function(_content) {
             this.content = _content;
             var _client = document.body.clientWidth;
             var _css = new String();
             _css += 'top: ' + this.top + 'px;';
             _css += 'width: ' + this.width + 'px;';
             _css += 'height: ' + this.height + 'px;';
             _css += 'position: absolute;';
             _css += 'font-size: 12px;';
             _css += 'border: 1px solid menu;';
             _css += 'overflow: auto;'
             var _html = new String();
             _html += '<div id="oCouplet_left" style="' + _css + 'left: ' + this.offset + 'px;">';
             _html += this.content;
             _html += '</div>';
             _html += '<div id="oCouplet_right" style="' + _css + 'left: ' + (_client - this.width - this.offset) + 'px;">';
             _html += this.content;              
             _html += '</div>';
             return _html;
        }
       
        this.doScroll = function() {
             var _left = document.getElementById('oCouplet_left');
             var _right = document.getElementById('oCouplet_right');
             var _oTop = parseInt(_left.style.top);
             var _nTop = parseInt(document.body.scrollTop) + this.top;
             if (_oTop < _nTop) {
                 if ((_nTop - _oTop) > 0) {
                      _left.style.top = _right.style.top = _oTop + 1 + 'px';
                      var oTime = window.setTimeout('oCouplet.doScroll()', this.delay);
                 } else {
                      window.clearTimeout(oTime);         
                 }
             } else {
                 if ((_oTop - _nTop) > 0) {
                      _left.style.top = _right.style.top = _oTop - 1 + 'px';
                      var oTime = window.setTimeout('oCouplet.doScroll()', this.delay);
                 } else {
                      window.clearTimeout(oTime);       
                 }
             }
        }
    }


    window.onload = function() {
        var oTop = 50, oWidth = 120, oHeight = 250, oOffset = 20;
        var oDelay = 80, oAmount = 1;
        oCouplet = new Couplet(oTop, oWidth, oHeight, oOffset, oDelay, oAmount);
        with (document.body) {
              innerHTML += oCouplet.drawCouplet(self.oContent.innerHTML);
              onscroll = function() {
                   oCouplet.doScroll();
              }    
        }   
    }      
</script>
<comment id="oContent">
    <div align="center">
         <br>对联内容
    </div>
</comment>

 

 

<pre>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


</pre>
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值