Detect between a mobile browser or a PhoneGap application
cordova, javascript, jquery, mobile
Solution
You could check if the current URL contains `http` protocol.
var app = document.URL.indexOf( 'http://' ) === -1 && document.URL.indexOf( 'https://' ) === -1;
if ( app ) {
// PhoneGap application
} else {
// Web page
}
Problem
Is it possible to detect if the user is accessing through the browser or application using JavaScript? I'm developing a hybrid application to several mobile OS through a web page and a PhoneGap application and the goal would be to: - Use the same code independently of the deployment target - Add PhoneGap.js file only when the user agent is an application