Detect between a mobile browser or a PhoneGap application

后端 未结 16 1959
小蘑菇
小蘑菇 2020-11-28 03:03

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

16条回答
  •  情话喂你
    2020-11-28 03:26

    Nobody mentioned this yet, but it seems Cordova now supports adding the browser as a platform:

    cordova platforms add browser
    

    This will automatically add cordova.js during run-time, which features the onDeviceReady event, so that you do not need to fake it. Also, many plugins have browser support, so no more browser hacks in your code.

    To use your app in the browser, you should use cordova run browser. If you want to deploy it, you can do so using the same commands as the other platforms.

    EDIT: forgot to mention my source.

提交回复
热议问题