Prevent autohide of address bar on mobile browsers
Is there any way to prevent the autohide of addressbar on scroll?
Unfortunately, there is no way to pin the address bar from HTML or code (that I know of, at least).
"Fake" fullscreen mode:
Instead, you could consider forcing the address-bar to auto-hide when the page loads, to give a nicer full-screen experience.
Obviously, this will only apply when first loading the page and scrolling down - back up again, it will show the address bar.
I tend to find that most mobile-designed sites require the user to scroll down a lot, and then navigate to another page anyway.
Here's how:
Write a simple script and use it in the page(s) you wish to have as "full-screen" - or if you have a template page which the rest of your site uses, use the script in that.
You can use:
<script type="text/javascript">
window.onLoad = function() {
window.scrollTo(0,1);
}
</script>
Or if you're using jQuery:
<script type="text/javascript">
$(function() {
$(window).scrollTo(0,1);
}
</script>
This "tricks" the browser into thinking that you've already scrolled when the page loads, and therefore auto-hides the address bar. This may/may not work on certain browsers.
Again - this is not a direct answer to "preventing autohide of addressbar on scroll", but this may enhance your users' experience when first visiting pages.
I used: http://www.html5rocks.com/en/mobile/fullscreen/ as a reference - by the looks of it, there are plenty more other ideas, too.
Hope this helps! :)
UPDATE:
I've done a lot more digging on this subject, and there also appears to be other ways that you can force the browser into being "full-screen", and also to prevent the address bar from re-appearing when scrolling "up".
See here: http://www.creativebloq.com/html5/12-html5-tricks-mobile-81412803 for some (plenty of) suggestions.
Disable hiding of address bar on mobile
You can wrap your HTML with div
and do something like this: http://jsfiddle.net/DerekL/Fhe2x/show
$("html, body, #wrapper").css({
height: $(window).height()
});
It works on Android and iOS.
Related Topics
Serving Gzipped CSS and JavaScript from Amazon Cloudfront via S3
How to Get a Leaflet Map Canvas to Have a 100% Height
Call Java Function from JavaScript Over Android Webview
Problem Deploying Rails 3.1 Project to Heroku: Could Not Find a JavaScript Runtime
How to Group Data with an Angular Filter
Cross-Browser JavaScript Xml Parsing
Sum JavaScript Object Propertya Values With the Same Object Propertyb in an Array of Objects
How to Round to 1 Decimal Place in JavaScript
Does JavaScript Have "Short-Circuit" Evaluation
Converting JavaScript Object With Numeric Keys into Array
Convert Dropdown to Selection Boxes with Color and Trigger Drop Down Action
Making Facebook Login Work with an Android Webview
Rails: Post 422 (Unprocessable Entity) in Rails? Due to the Routes or the Controller
Jquery Selector for Inputs with Square Brackets in the Name Attribute
Sign PDF with Plain JavaScript
Backslashes - Regular Expression - JavaScript
How to Show Live Preview in a Small Popup of Linked Page on Mouse Over on Link