Created
August 2, 2013 17:49
-
-
Save Boztown/6141869 to your computer and use it in GitHub Desktop.
Test for PhoneGap. (from: http://stackoverflow.com/questions/8068052/phonegap-detect-if-running-on-desktop-browser).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine whether the file loaded from PhoneGap or not | |
*/ | |
function isPhoneGap() { | |
return (cordova || PhoneGap || phonegap) | |
&& /^file:\/{3}[^\/]/i.test(window.location.href) | |
&& /ios|iphone|ipod|ipad|android/i.test(navigator.userAgent); | |
} | |
if ( isPhoneGap() ) { | |
alert("Running on PhoneGap!"); | |
} else { | |
alert("Not running on PhoneGap!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment