document.documentElement.scrollTop Google Chrome 不 兼容

   SetScroll();       

  function SetScroll() {

            if (window.attachEvent) {         

        window.attachEvent("onscroll", SaveScrollValue);     

        }           

  else {      

           window.addEventListener("scroll", SaveScrollValue, false);       

         }        

}         

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(SetScrollValue);     

 

     function SaveScrollValue(sender, args) {

            var scrollTemp = document.getElementById("<%=HiddenFieldScroll.ClientID%>");     

        if (scrollTemp != null)            

     scrollTemp.value = document.body.scrollTop + document.documentElement.scrollTop;     

    }

 

        function SetScrollValue(sender, args) {        

            var scrollTemp = document.getElementById("<%=HiddenFieldScroll.ClientID%>");       

      if (scrollTemp != null)             {       

          //window.scroll(0, scrollTemp.value);     

            document.documentElement.scrollTop = scrollTemp.value;        

         if (document.documentElement.scrollTop == 0) {        

             document.body.scrollTop = scrollTemp.value;    

             }                     

       }  

       }

 

posted @ 2012-12-24 18:19  yangfeizbj  阅读(220)  评论(0编辑  收藏  举报