Team:AHUT China/scrolltop

From 2014.igem.org

(Difference between revisions)
Box@igem (Talk | contribs)
(Created page with "function goTopEx(){ var obj=document.getElementById("goTopBtn"); function getScrollTop(){ return document.documentElement.scrollTop; }...")
Newer edit →

Revision as of 01:04, 17 October 2014

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);
               }
       }
   }