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

前端 未结 9 425
太阳男子
太阳男子 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:34

    Ended up pulling out the StopGap code and having to introduce a tiny delay (have this code running in a separate script than page-specific code):

    window.setTimeout(function() {
        var e = document.createEvent('Events'); 
        e.initEvent("deviceready", true, false); 
        document.dispatchEvent(e);
    }, 50);
    

提交回复
热议问题