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 thr
The way I'm doing it with is using a global variable that is overwritten by a browser-only version of cordova.js. In your main html file (usually index.html
) I have the following scripts that are order-dependent:
And inside cordova.js
I have simply:
__cordovaRunningOnBrowser__ = true
When building for a mobile device, the cordova.js will not be used (and instead the platform-specific cordova.js file will be used), so this method has the benefit of being 100% correct regardless of protocols, userAgents, or library variables (which may change). There may be other things I should include in cordova.js, but I don't know what they are yet.