How to fire deviceready event in Chrome browser (trying to debug phonegap project)

前端 未结 9 461
太阳男子
太阳男子 2020-12-23 16:09

I\'m developing a PhoneGap application and I\'d like to be able to debug it in Chrome rather than on the phone. However, I do the initialization of my code in an onDeviceRe

9条回答
  •  难免孤独
    2020-12-23 16:42

    Add this code to your onLoad handler function:

        if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {
            document.addEventListener("deviceready", onDeviceReady, false);
        } else {
            onDeviceReady();
        }
    

    Event "deviceready" is fired in cordova.js so I don't know a way to detect existence of this event in application code.

提交回复
热议问题