在PhoneGap的项目警报功能不会在Android模拟器工作 [英] the alert function in phonegap program does not work in the android emulator

查看:133
本文介绍了在PhoneGap的项目警报功能不会在Android模拟器工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 现在,我所面临的问题,当我运行该项目在LogCat中


  

1的TAG-跟踪TEXT-错误打开跟踪文件:没有这样的文件或目录中(2)


当我点击为其的onclick函数的定义我没有得到任何的错误状态文本


  

2的TAG-Web控制台TEXT-未捕获类型错误:无法调用未定义的方法'警报'的文件:///android_assets/www.index.html:27


  
  

navigator.notification.alert(


我的编码是

 < HTML和GT;
  < HEAD>
    <脚本类型=文/ JavaScript的字符集=utf-8SRC =科尔多瓦-2.4.0.js>< / SCRIPT>
    <脚本类型=文/ JavaScript的字符集=utf-8>    //等待科尔多瓦加载
    //
    document.addEventListener(deviceready,onDeviceReady,FALSE);    //科尔多瓦准备就绪
    //
    功能onDeviceReady(){
        //空
    }    //警告对话框驳回
    功能alertDismissed(){
        // 做一点事
    }    //显示一个定制alertDismissed
    //
    功能showAlert(){
        navigator.notification.alert(
            你就是赢家!',//消息
            alertDismissed,//回调
            '游戏结束',//称号
            完成// BUTTONNAME
        );
    }    < / SCRIPT>
  < /头>
  <身体GT;
    < P>< A HREF =#的onclick =showAlert();返回false;>显示警报< / A>< / P>
  < /身体GT;
< / HTML>在加速度计项目无关的情况下,除了自带无论是在段落标记...其中,我会犯的错误给予...我有没有关于它的想法。**我曾尝试与几乎所有的例子,但报警功能不起作用**
**我试图左右逢源尝试与榜样,然后通过复制所有文件,如罐子,cordova.js,XML和科尔多瓦文件夹**现在我应该做的?请帮忙!!!


解决方案

 如果(networkState == Connection.NONE)
{
  警报('没有互联网连接');
 };

now,the problem i am facing when i run the project in the LogCat

1 the TAG-Trace TEXT-error opening trace file:no such file or directory found (2)

when i click on the text for which onclick function is defined i don't get anything the error states

2 the TAG-web console TEXT-uncaught Typeerror:cannot call the method 'alert' of undefined at file:///android_assets/www.index.html:27

navigator.notification.alert(

my coding is

    <html>
  <head>


    <script type="text/javascript" charset="utf-8" src="cordova-2.4.0.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is ready
    //
    function onDeviceReady() {
        // Empty
    }

    // alert dialog dismissed
    function alertDismissed() {
        // do something
    }

    // Show a custom alertDismissed
    //
    function showAlert() {
        navigator.notification.alert(
            'You are the winner!',  // message
            alertDismissed,         // callback
            'Game Over',            // title
            'Done'                  // buttonName
        );
    }

    </script>
  </head>
  <body>
    <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
  </body>
</html>

in the case of the Accelerometer project nothing comes except whatever is given in the paragraph tag...where would i have committed mistake...i have no idea about it.

**i have tried with almost all the examples but the alert function does not function**


**i have tried both ways trying out with the example and then by copying all the files like the jar,cordova.js,xml and cordova folder**

now what should i do??? please help!!!

解决方案

if (networkState == Connection.NONE)
{
  alert('No internet connection ');
 };

这篇关于在PhoneGap的项目警报功能不会在Android模拟器工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆