Reputation: 612
I've tried to fire an alert on document.ready in a JavaScript file but the alert didn't fire when testing on Windows Phone 7 emulator. btw I uses PhoneGap 2.2.0, JS, and HTML here is my code
$(document).ready(function () {
alert("Hello World WP7");
initPlateImage();
});
also I've tried
window.alert = navigator.notification.alert;
and
navigator.notification.alert("Hi");
but no use, Any suggestions Thanks!
Upvotes: 1
Views: 1310
Reputation: 2623
Probably Cordova is not initialized at the time you call alert(). Try the following way - "deviceready" is an Cordova specific event telling you that Cordova is successfully initialized
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady()
{
// IE does NOT provide an alert method, you can patch it with this line after deviceready.
window.alert = window.alert || navigator.notification.alert;
alert("Hello World WP7");
}
Upvotes: 1