Results 1 to 2 of 2

Thread: "jQuery Scroll to Top Control v1.1" - Number of pixels from the bottom of the page

  1. #1
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question "jQuery Scroll to Top Control v1.1" - Number of pixels from the bottom of the page

    1) Script Title: jQuery Scroll to Top Control v1.1

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex3/scrolltop.htm

    3) Describe problem: I have this page on my website, which I update it regularly, so the page length changes in time (goes up and down).

    The jQuery says: the number of pixels the user's scrollbar should be from the top of the page before revealing the control.

    How can I make it from the bottom of the page?

    Thank you.

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!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" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style type="text/css">
    /*<![CDATA[*/
    #scrolltop {
      position:fixed;z-Index:101;bottom:5px;right:5px;width:100px;
    }
    
    
    /*]]>*/
    </style></head>
    
    <body>
    <div style="height:2000px;" ></div>
    <img id="scrolltop" src="http://www.vicsjavascripts.org/StdImages/1.gif" />
    
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function zxcScrollTop(o){
     var t=document.getElementById(o.MarkID),y=o.Bottom,ms=o.Animate,b=document.createElement('DIV');
     if (t&&typeof(y)=='number'&&y>0){
      b.style.width=b.style.height='0px';
      document.body.appendChild(t);
      document.body.appendChild(b);
      this.t=t;
      this.y=y;
      this.b=b;
      this.ms=typeof(ms)=='number'&&ms>0?ms:1000;
      this.addevt(t,'click','top');
      this.addevt(window,'scroll','scroll');
      this.s=[0,0];
      this.f=[t,0];
      this.scroll();
     }
    }
    
    zxcScrollTop.prototype={
    
     scroll:function(){
      var s=window.innerHeight?window.pageYOffset:document.documentElement.clientHeight?document.documentElement.scrollTop:document.body.scrollTop;
      var g=s<this.b.offsetTop-this.y;
      if (this.g!=g){
       this.t.style.visibility='visible';
       this.animate(this.f,this.f[1],g?0:100,new Date(),this.ms);
      }
      this.s[1]=s;
      this.g=g;
     },
    
     top:function(){
      this.animate(this.s,this.s[1],0,new Date(),this.ms);
     },
    
    
     animate:function(a,f,t,srt,mS){
      clearTimeout(a[4]);
      var oop=this,ms=new Date()-srt,n=(t-f)/mS*ms+f;
      if (isFinite(n)){
       a[1]=n;
       a==oop.s?window.scrollTo(0,n):oop.opc(a[0],n);
      }
      if (ms<mS){
       a[4]=setTimeout(function(){ oop.animate(a,f,t,srt,mS); },10);
      }
      else {
       a[1]=t;
       a==oop.f&&t==0?a[0].style.visibility='hidden':null;
      }
     },
    
     opc:function(o,n){
      o.style.filter='alpha(opacity='+n+')';
      o.style.opacity=o.style.MozOpacity=o.style.WebkitOpacity=o.style.KhtmlOpacity=n/100-.001;
     },
    
     addevt:function(o,t,f,p,p1){
      var oop=this;
      o.addEventListener?o.addEventListener(t,function(e){ return oop[f](p,p1);},false):o.attachEvent?o.attachEvent('on'+t,function(e){ return oop[f](p,p1); }):null;
     }
    
    
    }
    
    new zxcScrollTop({
     MarkID:'scrolltop',
     Bottom:1000,
     Animate:1000
    })
    /*]]>*/
    </script>
    
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Similar Threads

  1. jQuery Scroll to Top Control for custom links
    By sylver in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 02-16-2012, 08:12 AM
  2. jQuery Scroll to Top Control
    By pookeyblow in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 09-17-2011, 07:13 AM
  3. jQuery Scroll to Top Control doesn't work >.<
    By Emeralda in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 06-26-2011, 09:51 AM
  4. Add "scroll to bottom" option to "jQuery Scroll to Top Control v1.1"
    By YesHoney in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 10-10-2010, 04:55 PM
  5. jQuery Scroll to Top Control v1.1 Error
    By quddusaliquddus in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-30-2009, 05:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •