PhoneGap: Detect if running on desktop browser

后端 未结 30 2863
时光取名叫无心
时光取名叫无心 2020-11-29 15:47

I\'m developing a web application that uses PhoneGap:Build for a mobile version and want to have a single codebase for the \'desktop\' and mobile versions. I want to be able

30条回答
  •  孤城傲影
    2020-11-29 16:04

    I use a combination of what GeorgeW and mkprogramming suggested:

       if (!navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {
          onDeviceReady();
       } else if (Phonegap.available){
          onDeviceReady();
       } else {
          console.log('There was an error loading Phonegap.')
       }
    

提交回复
热议问题