5

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.

Alexander
  • 921
  • 3
  • 12
  • 31

1 Answers1

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
  • Actually it doesn't. Can you explain the theory? – Alexander Aug 19 '16 at 09:05
  • 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