Detect between a mobile browser or a PhoneGap application

后端 未结 16 1956
小蘑菇
小蘑菇 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:29

    It sounds like you are loading another webpage once the webview starts in the Phonegap app, is that correct? If that's true then you could add a param to the request url based on configuration.

    For example, assuming PHP,

    App.Config = {
      target: "phonegap"
    };
    
    
    
    var onbodyload = function () {
      var target = App.Config.target;
      document.location = "/home?target=" + target;
    };
    

    Then on the server side, include the phonegap js if the target is phonegap.

    There is no way to detect the difference using the user agent.

提交回复
热议问题