简体   繁体   English

使用JavaScript和PhoneGap的Windows Phone 7模拟器上不会触发警报

[英]Alert doesn't fire on Windows Phone 7 emulator using JavaScript and PhoneGap

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. 我试图在JavaScript文件中对document.ready发出警报,但是在Windows Phone 7模拟器上进行测试时,警报并未触发。 btw I uses PhoneGap 2.2.0, JS, and HTML here is my code 顺便说一句,我使用PhoneGap 2.2.0,JS和HTML,这是我的代码

$(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! 但没用,有什么建议谢谢!

Probably Cordova is not initialized at the time you call alert(). 调用alert()时,可能未初始化Cordova。 Try the following way - "deviceready" is an Cordova specific event telling you that Cordova is successfully initialized 请尝试以下方式-“ deviceready”是Cordova特定事件,告诉您Cordova已成功初始化

    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");


    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM