Team:AHUT China/scrolltop

From 2014.igem.org

Revision as of 01:04, 17 October 2014 by Box@igem (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

function goTopEx(){

       var obj=document.getElementById("goTopBtn");
       function getScrollTop(){
               return document.documentElement.scrollTop;
           }
       function setScrollTop(value){
               document.documentElement.scrollTop=value;
           }    
       window.onscroll=function(){getScrollTop()>0?obj.style.background="url(images/AHUT_CHINA_2014_left_bar_top.png) 0 -130px":obj.style.background="url(images/AHUT_CHINA_2014_left_bar_app.png) 0 -130px";}
       obj.onclick=function(){
           var goTop=setInterval(scrollMove,10);
           function scrollMove(){
                   setScrollTop(getScrollTop()/1.1);
                   if(getScrollTop()<1)clearInterval(goTop);
               }
       }
   }