Reputation: 16430
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!)
Upvotes: 4
Views: 4232
Reputation: 4532
It's just:
first checking if the object window.navigator has a property called "standalone"
then comparing the property window.navigator.standalone to FALSE -> !window.navigator.standalone is the same as window.navigator.standalone != true
Upvotes: 1
Reputation: 5922
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.
Upvotes: 4