<!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 ">
<kepala>
<meta http-equiv="Jenis Konten" content="teks/html; charset=gb2312" />
<judul></judul>
</kepala>
<tubuh>
<skrip tipe="teks/javascript">
var $ = fungsi (id) {
kembalikan "string" == typeof id ? dokumen.getElementById(id) : id;
};
var Kelas = {
buat: fungsi() {
fungsi kembali() {
this.initialize.apply(ini, argumen);
}
}
}
Objek.extend = function(tujuan, sumber) {
for (var PROperty di sumber) {
tujuan[properti] = sumber[properti];
}
tujuan kembali;
}
fungsi addEventHandler(oTarget, sEventType, fnHandler) {
if (oTarget.addEventListener) {
oTarget.addEventListener(sEventType, fnHandler, false);
} else if (oTarget.attachEvent) {
oTarget.attachEvent("aktif" + sEventType, fnHandler);
} kalau tidak {
oTarget["aktif" + sEventType] = fnHandler;
}
};
var Scroller = Kelas.buat();
Scroller.prototipe = {
inisialisasi: function(idScroller, idScrollMid, options) {
var oScroll = ini, oScroller = $(idScroller), oScrollMid = $(idScrollMid);
this.heightScroller = oScroller.offsetHeight;
this.heightList = oScrollMid.offsetHeight;
if(ini.heightList <= this.heightScroller) kembali;
oScroller.style.overflow = "tersembunyi";
oScrollMid.appendChild(oScrollMid.cloneNode(benar));
this.oScroller = oScroller;
this.timer = null;
this.SetOptions(pilihan);
this.side = 1;//1是上 -1是下
beralih (ini.pilihan.Sisi) {
kasus "turun":
ini.sisi = -1;
merusak;
kasus "naik":
bawaan :
ini.sisi = 1;
}
addEventHandler(oScrollMid , "mouSEOver", function() { oScroll.Stop(); });
addEventHandler(oScrollMid , "mouseout", function() { oScroll.Start(); });
if(ini.options.PauseStep <= 0 || this.options.PauseHeight <= 0) this.options.PauseStep = this.options.PauseHeight = 0;
ini.Jeda = 0;
ini.Mulai();
},
//设置默认属性
SetOptions: fungsi(opsi) {
this.options = {//默认值
Langkah: 1,//每次变化的px量
Waktu: 20 //速度(越大越慢)
Sisi: "naik",//滚动方向:"naik"是上,"turun"是下
PauseHeight: 0,//隔多高停一次
PauseStep: 1000//停顿时间(PauseHeight大于0该参数才有效)
};
Objek.memperluas(ini.pilihan, pilihan || {});
},
//滚动
Gulir: fungsi() {
var iScroll = this.oScroller.scrollTop, iHeight = this.heightList, time = this.options.Time, oScroll = ini, iStep = this.options.Step * this.side;
if(sisi ini > 0){
if(iScroll >= (iHeight * 2 - this.heightScroller)){ iScroll -= iHeight; }
} kalau tidak {
if(iGulir <= 0){ iGulir += iTinggi; }
}
if(ini.pilihan.PauseHeight > 0){
if(ini.Jeda >= ini.pilihan.PauseHeight){
waktu = ini.options.PauseStep;
ini.Jeda = 0;
} kalau tidak {
ini.Jeda += Math.abs(iStep);
this.oScroller.scrollTop = iScroll + iStep;
}
} else { this.oScroller.scrollTop = iScroll + iStep; }
this.timer = window.setTimeout(function(){ oScroll.Scroll(); }, waktu);
},
//开始
Mulai: fungsi() {
ini.Gulir();
},
//停止
Berhenti: fungsi() {
clearTimeout(ini.timer);
}
};
jendela.onload = fungsi(){
Scroller baru("idScroller", "idScrollMid",{ PauseHeight:25 });
}
</skrip>
<gaya>
#idScroller *{margin:0px; bantalan:0 piksel;}
#idScroller{tinggi baris:25px;lebar:100%; tinggi:25 piksel; meluap: tersembunyi; batas:1 piksel padat #000000;}
#idScroller ul{lebar:100%}
#idScroller li{lebar:20%; mengapung:kiri; meluap: tersembunyi; gaya daftar:tidak ada;}
</gaya>
<div id="idScroller">
<div id="idScrollMid">
<ul>
<li> <a href=" http://www.devdao.com/">www.devdao.com</a></li >
<li> <a href=" http://www.devdao.com/">www.devdao.com</a></li >
<li> <a href=" http://www.devdao.com/">www.devdao.com</a></li >
<li> <a href=" http://www.devdao.com/">www.devdao.com</a></li >
<li> <a href=" http://www.devdao.com/">www.devdao.com</a></li >
<li> <a href=" http://www.devdao.com/">www.devdao.com</a></li >
</ul>
<div style="hapus:keduanya;"></div>
</div>
</div>
</tubuh>
</html>