非常不错的一个javascript 类_javascript技巧_脚本之家

非常不错的一个javascript 类复制代码
代码如下:/* *Author:aoao *Homepage:
*Email:loaoao@gmail.com/QQ:2222342 *Copyright2006aoao
*LicensedunderaCreativeCommonsAttribution2.5License()
*/ varjscc=newObject(); varloaoao=newObject();//^_^// jscc={
init:function(){/*_*/}, path:”/scripts/jscc/”, include:function{
varj=document.createElement; j.setAttribute(‘type’,’text/javascript’);
j.setAttribute(‘src’,jscc.path+file+’.js’);
document.getElementsByTagName[0].appendChild; } };
jscc.addEvent=function{ if{ obj[‘e’+type+fn]=fn;
obj[type+fn]=function(){obj[‘e’+type+fn];}
obj.attachEvent(‘on’+type,obj[type+fn]); }else{ obj.addEventListener;
} }; //Cookies jscc.cookie={ create:function{ if{ vardate=newDate();
date.setTime+; varexpires=”;expires=”+date.toGMTString(); }
elseexpires=””; document.cookie=name+”=”+value+expires+”;path=/”; },
read:function{ varnameEQ=name+”=”; varca=document.cookie.split;
for(vari=0;idocument.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth);
theHeight=((document.body.scrollHeight>document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight);
} varwinWidth,winHeight; if{ winWidth=self.innerWidth;
winHeight=self.innerHeight;
}elseif(document.documentElement&&document.documentElement.clientHeight){
winWidth=document.documentElement.clientWidth;
winHeight=document.documentElement.clientHeight; }elseif{
winWidth=document.body.clientWidth;
winHeight=document.body.clientHeight; }
varpWidth=(theWidth>winWidth?theWidth:winWidth)
varpHeight=(theHeight>winHeight?theHeight:winHeight) varyScroll; if{
yScroll=self.pageYOffset;
}elseif(document.documentElement&&document.documentElement.scrollTop){//Explorer6Strict
yScroll=document.documentElement.scrollTop; }elseif{//allotherExplorers
yScroll=document.body.scrollTop; }
vargetPageSize=newArray(pWidth,pHeight,winWidth,winHeight,yScroll)
returngetPageSize; } jscc.widgets={/**/}; jscc.widgets.fixedsidebar={
fixedHeight:0, oldScrolltop:0, init:function(){
if(!document.getElementByIdreturn;
jscc.addEvent(window,”scroll”,function{jscc.widgets.fixedsidebar.setFixed;
jscc.addEvent(window,”resize”,function{jscc.widgets.fixedsidebar.setFixed;
this.fixedHeight=document.getElementById.offsetTop; this.setFixed(); },
setFixed:function(){ varsidebar=document.getElementById;
varref=document.getElementById; vars_t=sidebar.offsetTop;
vars_h=sidebar.offsetHeight; vars_th=s_t+s_h;
varr_th=ref.offsetTop+ref.offsetHeight; vard_st;
if(document.documentElement.scrollTop){
d_st=document.documentElement.scrollTop; } else{
d_st=document.body.scrollTop } if{ varseHeight=0;
if{seHeight=self.innerHeight;}elseif(document.documentElement&&document.documentElement.clientHeight){seHeight=document.documentElement.clientHeight;}elseif{seHeight=document.body.clientHeight;}
try{ if{ varnewtop=(d_st0) { casetrue:
if(d_st-this.fixedHeight>s_t-seHeight){
varnewtop=d_st-this.fixedHeight–68; } break; casefalse:
if(d_st-this.fixedHeight10;i-=Math.floor{ window.scrollTo; }
window.scrollTo; } else{ window.scrollTo; if{
waitTimer=setTimeout(“jscc.widgets.toTop.set; } else{ clearTimeout; } }
} } jscc.api={ google:{ init:function(){ try{
varsearchControl=newGSearchControl{ return; }
varoptions=newGdrawOptions();
options.setSearchFormRoot(document.getElementById;
options.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
searchControl.setLinkTarget(GSearch.LINK_TARGET_SELF);
searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
varsiteSearch=newGwebSearch(); siteSearch.setUserDefinedLabel;
siteSearch.setUserDefinedClassSuffix; siteSearch.setSiteRestriction;
searchControl.addSearcher; varlabSearch=newGwebSearch();
labSearch.setUserDefinedLabel; labSearch.setUserDefinedClassSuffix;
labSearch.setSiteRestriction; searchControl.addSearcher;
varwwwSearch=newGwebSearch(); wwwSearch.setUserDefinedLabel;
labSearch.setUserDefinedClassSuffix; searchControl.addSearcher;
searchControl.draw(document.getElementById(“googleSearchResults”),options);
//searchControl.execute; } } } loaoao.com=function(){
if(!document.getElementById)return; jscc.widgets.styleSwitcher.init();
jscc.widgets.fixedsidebar.init(); jscc.widgets.toTop.init();
jscc.api.google.init(); }; jscc.addEvent(window,”load”,loaoao.com);

发表评论

电子邮件地址不会被公开。 必填项已用*标注