今天写的一个练习的js类模式
suspendcode=""
document.write(suspendcode);
var hp = {
lastScrollY : 0,
byID : function(_id){ return document.getElementById(_id);},
init : function(id){
var st = document.documentElement.scrollTop || document.body.scrollTop;
percent=.1*(st-this.lastScrollY);
if(percent>0){
percent=Math.ceil(percent);
}else{
percent=Math.floor(percent);
}
this.byID(id).style.top=parseInt(this.byID(id).style.top)+percent+"px";
this.lastScrollY=this.lastScrollY+percent;
return id;
},
generate : function(){
},
start : function(id){
window.setInterval("hp.init(’"+id+"’)",1);
}
};
#hp.start(’lovexin1′);
Tags: html, js, oo, 滚动
This entry was posted
on 星期三, 六月 10th, 2009 at 19:36 and is filed under 默认分类.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.