21

In an attempt to hide the Safari UI components for an web-app bookmarked as a Homescreen Icon. I am using this meta tag

<meta name="apple-mobile-web-app-capable" content="yes" />

as specified on iPhone Dev Center but the address bar and toolbar are still there when launched from the home screen icon. What do I need to do different? Does anyone have an example?

Cœur
  • 37,241
  • 25
  • 195
  • 267

13 Answers13

30
window.top.scrollTo(0, 1);

Works on iPhone, but not in iPad. I have been successful hiding the browser components on iPad (so presumably everywhere) by using

<meta name="apple-mobile-web-app-capable" content="yes" />

and launching from a home-screen link. I am also using

<meta name="viewport" 
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

I have not tried seeing if the browser components are still hidden if I leave out the viewport properties.

Steve Jorgensen
  • 11,725
  • 1
  • 33
  • 43
  • The first option is the only thing that worked for me. I added And it worked. All the other options weren't working for me at all. – Jorge Pedret Aug 04 '11 at 05:20
  • same here, scrollTo(0,1) makes the address bar go away, but the meta tags appear to have no impact on it. – chovy Sep 15 '11 at 18:46
  • 3
    An important note on `apple-mobile-web-app-capable`, if you already have the application bookmarked, delete the bookmark and re-add to enable the change. – Chris Baxter Dec 10 '12 at 19:01
  • Is there any other way, instead of 'launching from a home-screen link' to make it work on iPad? – Ganesh Jadhav Sep 11 '13 at 12:47
7

Is it being launched from the home screen? The documentation on the linked page does not mention but I found this @ Configuring Web Applications:

For example, you can specify an icon for your web application used to represent it when added to the Home screen, as described in “Specifying a Webpage Icon for Web Clip.” You can also minimize the Safari on iPhone user interface, as described in “Changing the Status Bar Appearance” and “Hiding Safari User Interface Components,” when your web application is launched from the Home screen. These are all optional settings that when added to your web content are ignored by other platforms

crashmstr
  • 28,043
  • 9
  • 61
  • 79
  • 1
    Here's the updated link: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html – EMMERICH Jun 15 '11 at 07:36
  • Spot on crashmstr. The meta tags only work... WHEN THE APP IS LAUNCHED FROM THE HOME SCREEN. – Brett Hannah Jan 31 '12 at 14:34
6

Have you tried adding...

<meta name="apple-touch-fullscreen" content="yes" />
Benoit
  • 680
  • 1
  • 6
  • 17
  • this is undocumented. probably not used in stable releases of Mobile Safari. – Raptor Nov 12 '12 at 02:28
  • Indeed, cannot find a reference for this anymore (wrote in 2010). Looks like only `` is advised today (see [here](http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html)) – Benoit Mar 22 '13 at 10:40
3

From what I can tell, iOS only pays attention to the flags when you actually add the app. If the apple-mobile-web-app-capable thingy doesn't work at first, try deleting your app from the home screen then re-adding it.

I've run some experiments and found:

  • the location of the meta tag within the headers doesn't seem to matter (I thought it might!)
  • after adding the app and having it remove the address bar correctly, if you then remove the meta tags from the web page, iOS continues to remove the toolbar.
  • even after rebooting the device it still 'remembers' whether to remove the toolbar. The only way I've found of resetting this behaviour is to remove and re-add the app.

Hope that helps!

Jeremy W. Sherman
  • 35,901
  • 5
  • 77
  • 111
Andrew
  • 86
  • 3
2

There is a new directive, called "minimal-ui" that iOS browser takes into account (at least on the iPhone where I tested). Toolbars are hidden until the user clicks on the status bar on top. Very nice for one page apps!

Here is the snippet I use:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">

Cristian Dinu
  • 3,888
  • 1
  • 14
  • 7
2

I know this is pretty old, but I came across this while searching for a solution. I was able to fix this by also adding:

window.top.scrollTo(0, 1);

to the body's onload method. Hope it helps anyone else coming across this.

Chuck Norris
  • 15,207
  • 15
  • 92
  • 123
mbxtr
  • 2,323
  • 1
  • 15
  • 12
1

Try this

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width; user-scalable=0;">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="icon.png">
Pierre
  • 11
  • 1
1

Since iOS 7.1, you can use minimal-ui

<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">
B.Asselin
  • 978
  • 10
  • 19
0
<meta name="apple-mobile-web-app-capable" content="yes" />

This will work if:

  1. The tag exists when the app is added to the home screen.
  2. The app is launched from the home screen.
Samuel Lindblom
  • 812
  • 1
  • 6
  • 22
0
<meta name="apple-mobile-web-app-capable" content="yes" />

works on iOS6 + Mobile Safari Browser but ONLY if you added the page to your homescreen AFTER you included the meta tag on your site.

Charles Ingalls
  • 4,521
  • 5
  • 25
  • 33
0

all above meta tags and window.scrollTo, did not work on ipad for me, i found a button on safari next to bookmarks where you get an option called 'Add to Home Screen' it creates a new tile icon, and you can launch your web app like a native app, and no address bar there.

jsDebugger
  • 122
  • 2
  • 11
0

That should indeed behave as expected, I have used it in the past without any difficulties.

wisequark
  • 3,288
  • 20
  • 12