4

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!)

peterh
  • 11,875
  • 18
  • 85
  • 108
williamsandonz
  • 15,864
  • 23
  • 100
  • 186

2 Answers2

4

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.

timdream
  • 5,914
  • 5
  • 21
  • 24
1

It's just:

  1. first checking if the object window.navigator has a property called "standalone"

  2. then comparing the property window.navigator.standalone to FALSE -> !window.navigator.standalone is the same as window.navigator.standalone != true

Leon
  • 4,532
  • 1
  • 19
  • 24