Wednesday, January 8, 2014

PhoneGap: Detect File Loaded from Phonegap or Not

/** * 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!"); 
}

No comments:

Post a Comment