How to enable "always show" address bar in Chrome on a mobile device using Javascript?
In other words, don't hide when the user scrolls down.
Asked
Active
Viewed 2,246 times
5

Alexander
- 921
- 3
- 12
- 31
-
1You could fake scrolling, but it's tricky. – gcampbell Aug 16 '16 at 07:57
-
You can wrap your HTML with div set its height 100% – 4dgaurav Aug 16 '16 at 07:58
-
@thesaurabhway how would that work? As I see it, you still get a scrolling page and a hiding address bar – Alexander Aug 17 '16 at 09:26
1 Answers
2
You can create a div
, set the height to 100%
and use overflow-y:auto;
.
If you would copy this code and paste it into your project, you will see this is what you're looking for.
Please use this with caution, I personally love that chrome hides the navigation bar.
Example:
/* You NEED to set the container height */
html, body {
height:100%;
}
/* Then override the scrollbar by a custom scrollable element: */
.customnavigation {
height:100%;
overflow-y:auto;
}
<div class="customnavigation">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
<img src="http://placehold.it/150x150">
</div>

Randy
- 9,419
- 5
- 39
- 56
-
-
1@Alexander I've used a method like this for my page before, but you might need to adjust it slightly by giving it a `margin-top` and less height (`calc(100% - margin-top)`). The theorie is that this creates a box that has scrollable content, but the box itself is only as high as the page itself. Therefore, the `body` doesn't scroll, and doesn't trigger the header to be collapsed. – Randy Aug 19 '16 at 09:15
-
@Alexander You might find this useful http://stackoverflow.com/questions/25298443/force-address-bar-to-show-in-mobile-chrome-app – Randy Aug 19 '16 at 09:17
-
That actually does the trick. What's in your opininon best for getting the height of the page minus the address bar, window.height? – Alexander Aug 21 '16 at 20:58