Phillip Senn
Phillip Senn

Reputation: 47635

Getting started with Phonegap

I don't understand why I'm not getting an alert. There are no errors in the console, and I'm sure it is finding the PhoneGap.js file.

<!doctype html>
<html>
<body> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script src="/Matrix/PhoneGap/Inc/js/PhoneGap.js"></script>
<script>
function myDeviceReady() {
    alert('Ready!');
}

document.addEventListener("deviceready", myDeviceReady, false);
</script>
</body>
</html>

Edit: This is not working on my iPhone using either Safari or Google Chrome.

Upvotes: 0

Views: 88

Answers (2)

Phillip Senn
Phillip Senn

Reputation: 47635

You can get it to run in a Ripple emulator (see this link) but make sure use cordova.js not phonegap.js.

Upvotes: 1

ThinkingStiff
ThinkingStiff

Reputation: 65371

Try:

window.addEventListener( 'load', myDeviceReady );

Checking deviceready has many issues. I find it easier to poll for window.device (which only exists if Phonegap is initialized).

Upvotes: 2

Related Questions