Permalink
Browse files

fixed a bug in IE desktop, where calling scrollTop before domready wa…

…s trying to access the body element before it was present. Moved this logic to domready and all's well.
  • Loading branch information...
scottjehl
scottjehl committed Jun 20, 2011
1 parent 9fffcb6 commit fe79ad63a494134812fc8421230856ca5dd74103
Showing with 13 additions and 11 deletions.
  1. +13 −11 js/jquery.mobile.init.js
View
@@ -101,20 +101,22 @@
}
});
//check which scrollTop value should be used by scrolling to 1 immediately
//check which scrollTop value should be used by scrolling to 1 immediately at domready
//then check what the scroll top is. Android will report 0... others 1
//note that this initial scroll won't hide the address bar. It's just for the check.
window.scrollTo( 0, 1 );
$(function(){
window.scrollTo( 0, 1 );
//if defaultHomeScroll hasn't been set yet, see if scrollTop is 1
//it should be 1 in most browsers, but android treats 1 as 0 (for hiding addr bar)
//so if it's 1, use 0 from now on
$.mobile.defaultHomeScroll = ( !$.support.scrollTop || $(window).scrollTop() === 1 ) ? 0 : 1;
//if defaultHomeScroll hasn't been set yet, see if scrollTop is 1
//it should be 1 in most browsers, but android treats 1 as 0 (for hiding addr bar)
//so if it's 1, use 0 from now on
$.mobile.defaultHomeScroll = ( !$.support.scrollTop || $(window).scrollTop() === 1 ) ? 0 : 1;
//dom-ready inits
$( $.mobile.initializePage );
//dom-ready inits
$( $.mobile.initializePage );
//window load event
//hide iOS browser chrome on load
$window.load( $.mobile.silentScroll );
//window load event
//hide iOS browser chrome on load
$window.load( $.mobile.silentScroll );
});
})( jQuery, this );

0 comments on commit fe79ad6

Please sign in to comment.