Error loading external URL in Phonegap 2.5

2019-06-23 17:08发布

I created a new Phonegap 2.5 project from scratch, and I've been trying to load an external URL in it, but I keep getting input boxes popping up on startup before loading the actual URL. I first get a pop-up with the URL of the website, then in the input box it says "DeviceInfo","Device652321624". If I click Cancel, it pops up 2 more times before loading the website. On the website itself, it loads some relative URLs, but others cause the entire page to refresh and the input boxes to pop up again.

I set the URL by setting <content src="http://phonegap.example.com" />, which is just a regular website with Javascript. I even tried commenting out all Phonegap specific code (no more ondeviceready calls), but it still causes the problem. http://www.google.com loads for me, so I'm not sure what else to check. And it works with the Android version that I've developed.

If it helps, I've also seen this message in the XCode log: Resetting plugins due to page load.

2条回答
做自己的国王
2楼-- · 2019-06-23 17:40

I've had the exact same problem today. I fixed it by checking the include of the cordova.js file (this js is generated when you create the project using the create command. ( called cordova.js in the renamed cordova project version. probably phonegap.js in phonegap ?)

anyway my include was :

<script type="text/javascript" src="js/cordova.js"></script>

whereas je js file was in the project root :

I changed it to

<script type="text/javascript" src="cordova.js"></script>

and every things is fine now.

also, the 'create' command for Android generate a different js file. make sur that the new one generated for ios is used.

hope that helps !

查看更多
beautiful°
3楼-- · 2019-06-23 17:40

Problem is you are using android's cordova.js instead of ios's cordova.js. Just make sure you are using the proper one.

查看更多
登录 后发表回答