返回

网站中的滚动返回顶部代码_返回顶部小火箭_邢台网站建设

时间:2013-2-15  编辑:邢台网络公司
//添加静态方法
 $.extend({ 
  top:function(){
   scrollToAim(0,"slow");
  },
  footer:function(){
   scrollToAim(1,"slow");
  },
  toId:function(id){
   scrollToAim(id,"slow");
  },
  jTo:function(id,speed){
   scrollToAim(id,speed)
  }
 });
 //
 function scrollToAim(id,speed){
  var here;
  //滚动目标
  if(id==0){
   here=0;
  }else if(id==1){
   here=bodyHeight();
  }else{
   here=$("#"+id).offset().top;
  }
  //开始滑动
  if($.browser.safari){//非IE
   $("body").animate({scrollTop:here}, speed);
  }else{//IE
   $("html").animate({scrollTop:here}, speed);
  }
  return false;
 }
 
<<<1234>>>
回顶部
分享到: