iPhone WebApps, is there a way to detect how it was loaded? Home Screen vs Safari?

AnApprentice picture AnApprentice · Apr 29, 2010 · Viewed 14.9k times · Source

I have an iPhone Web App, and I'm interested in detecting if the app was loaded either from:

  1. iPhone Safari
  2. iPhone installed web app (via the add to my home screen) which loads without the safari bars.

Any ideas?

Answer

Sharjeel Aziz picture Sharjeel Aziz · Apr 29, 2010

You can determine whether a webpage is displayed in full-screen mode using the window.navigator.standalone read-only Boolean JavaScript property. https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

if (window.navigator.standalone) {
    // fullscreen mode

}