Search code examples
htmljquery-mobileiphone-standalone-web-app

Detecting standalone mode in iPhone


I am trying to detect if my jquerymobile app is running as an APP (i.e from home screen). My current code is:

if (window.navigator.standalone)
  Data.isRunningAsApp = true;

Problem is I've heard this code is better according to this

if (("standalone" in window.navigator) && !window.navigator.standalone) {}

I get what the first segment is doing (testing is the property exists) but I don't understand the second segment. (From a syntax perspective I thought I did, but it seems contradictory to me!)


Solution

  • Read the paragraph above the code example in the blog post. The if is detecting for a supported browser that is not in the app mode.