So, I've drunk the web-app kool-aid, and I'm switching from building Android native apps to building web apps.
But I'm having really bad problems on Android browsers with the address bar (update: specifically, my HTC Desire Z running Android 2.3.3, I'm not sure how many other versions it affects):
- Problem 1: While the page is loading, the address bar hides the top ~30px of content. (Why on earth does it do this?!)
- Problem 2: In some situations, the address bar won't go away - this occurs for me in portrait when the connection speed is slow.
So on some occasions, the address bar hides the top 30px of content permanently. This is seriously broken.
I borrowed some code from another StackOverflow question to try to fix this:
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 = nViewH / window.devicePixelRatio;
$('BODY').css('height',nViewH + 'px');
}
window.scrollTo(0,1);
}
But it doesn't seem to work reliably - not to mention that it's a horrible solution. What can I do?