<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>