Skip to content

Instantly share code, notes, and snippets.

@thunsaker
Created December 21, 2011 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thunsaker/1506631 to your computer and use it in GitHub Desktop.
Save thunsaker/1506631 to your computer and use it in GitHub Desktop.
Mobile Scroll to top, add extra height if needed
// Scroll to top, add extra height to make this possible
$(document).ready(function () {
if (navigator.userAgent.match(/Android/i)) {
window.scrollTo(0, 0); // reset in case prev not scrolled
var nPageH = $(document).height();
var nViewH = window.outerHeight;
if (nViewH > nPageH) {
nViewH -= 250;
$('body').css('height', nViewH + 'px');
}
window.scrollTo(0, 1);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment