Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I hide the address bar on iPhone?

How do I hide the address bar on iPhone?

I tried two different methods so far:

  • The scroll down one pixel trick with JavaScript on page load

  • And the following meta tags:

    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /><meta name="apple-mobile-web-app-capable" content="yes" />
    

Also this:

<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />

I am completely confused.

PS: Oh, I forgot a really important thing: the web page itself does not overflow the browser window. It probably is the reason why the 1 pixel scrolldown trick does not work.

I can't make it bigger, since the hit thing about the design, that everyone can scroll, but this page folds... :)

like image 564
Peter Szabo Avatar asked Nov 07 '10 10:11

Peter Szabo


People also ask

How do I hide the address bar in Safari?

Enter full screen mode, right-click anywhere around the address bar then click "Hide Toolbar" in the menu that appears. Although next time you enter full screen mode the toolbar comes back.

Can you move address bar back to top on iPhone?

Open the Settings app. Scroll down and tap Safari. Scroll down to the Tabs section and locate the option to switch between the Tab Bar and a Single Tab. Select Single Tab to move the Address Bar back to the top of the screen, or select Tab Bar to move it back to the bottom if you change your mind later on.


3 Answers

I just hit this myself. If the address bar is not hiding, the reason may simply be the page is not long enough to scroll.

When the

window.scrollTo(0,1)

is called the page MUST be longer than the window so a scrolling event can occur.

Only when the scrolling even occurs will mobile safari hide the address bar.

like image 150
rob Avatar answered Oct 19 '22 18:10

rob


🔴 UPDATE: Apple removed support for minimal-ui in iOS 8 so this is no longer a useful answer :(


For new googlers looking into this: As of iOS 7.1 there's a new minimal-ui mode that works on mobile Safari:

minimal-ui

It's enabled by setting the minimal-ui property on the viewport:

<meta name="viewport" content="minimal-ui">

You can also use it in conjunction with other properties like so:

<meta name="viewport" content="width=device-width, minimal-ui">

Of note, there's no minimum content length requirement as there is with the scrollTo hack. There's a great overview of this new mode here. (That's where the above image comes from.) He also lists some shortcomings.

The only official documentation I could find on this is a note in Apple's iOS 7.1 release notes:

A property, minimal-ui, has been added for the viewport meta tag key that allows minimizing the top and bottom bars on the iPhone as the page loads. While on a page using minimal-ui, tapping the top bar brings the bars back. Tapping back in the content dismisses them again.

For example, use <meta name="viewport" content="width=1024, minimal-ui”>.

Of course, since this only works in iOS 7.1 and above, it's usefulness may be limited.

like image 12
markquezada Avatar answered Oct 19 '22 19:10

markquezada


Unless something has changed in recent iOS versions, the scroll down trick is the only one that reliably works, I've had no issues with this version:

/mobile/i.test(navigator.userAgent) && !location.hash && setTimeout(function() {
  window.scrollTo(0, 1);
}, 1000);​

I didn't care about any other mobile platform for this particular page though, it was redirecting based on agent...you may want to change the regex to check for iPhone specifically, e.g. replace /mobile/ with /iPhone/.

like image 10
Nick Craver Avatar answered Oct 19 '22 19:10

Nick Craver