Phonegap将javascript通知替换为Phonegap通知



嗨,我的phonegap应用程序有问题

这是我的html代码

<body>
<script>
window.onload = function() {
    document.getElementById("a_next").onclick = function(e) {
        e = e || window.event;
        var els = document.getElementsByTagName("input"),
            i;
        for (i=0; i < els.length; i++) {
            if (!els[i].checked) {
                alert("Not all points on your checklist, are checked!");
                return false;
            }
        }
    };
};
</script>
<div id="topbar">
<div id="title">
        Walk Around Check</div>
    <div id="leftnav">
    <a href="index_aerosoft.html">Home</a><a href="katana_checklist_all.html">Overview</a></div>
    <div id="rightnav">
        <a href="katan_checklist_beforeenginestarting.html"id="a_next">Next</a></div>
</div>
<div id="content">
        <ul class="pageitem">
            <li class="radiobutton"><span class="name">Electronic List - check all items</span>
            <input name="1" type="radio" value="other" /></li>
        </ul>
</div>
<div id="footer">
        <!-- Support iWebKit by sending us traffic; please keep this footer on your page, consider it a thank you for my work :-) -->
    <a class="noeffect" href="katana_checklist_walaroundcheck.html">Reset Checklist</a><br /><br />
    <a class="noeffect" href="http://www.aerosoft.com">Aerosoft</a></div>
</body>

所以我想添加或替换javascript警报为phonegap警报

document.getElementById("a_next").onclick = function(e) {
            e = e || window.event;
            var els = document.getElementsByTagName("input"),
                i;
            for (i=0; i < els.length; i++) {
                if (!els[i].checked) {
                    alert("Not all points on your checklist, are checked!");
                    return false;
                }
            }
        };

所以我会在

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

并在javascript警报旁边发出警报

<body>
<script>
window.onload = function() {
    document.getElementById("a_next").onclick = function(e) {
        e = e || window.event;
        var els = document.getElementsByTagName("input"),
            i;
        for (i=0; i < els.length; i++) {
            if (!els[i].checked) {
                alert("Not all points on your checklist, are checked!");
                showAlert();
                return false;
            }
        }
    };
};
</script>

这不起作用,并打破了我的漏洞检查"所有都检查过了"有人能帮忙吗?

window.onload = function() {
    document.getElementById("a_next").onclick = function() {
        document.getElementsByTagName("input").each(function () {
            if (!jQuery(this).checked) {
                alert("Not all points on your checklist, are checked!");
                showAlert();
                return false;
            }
        });
    };
};

Versuchs mal damit代码解决方案不受阻碍。

在这里工作:

<!DOCTYPE html>
<html>
    <head>
        <title>Notification Example</title>
        <script type="text/javascript" charset="utf-8" src="cordova-2.3.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>  

这里它不起作用:

  <!DOCTYPE html>
    <html>
        <head>
            <title>Notification Example</title>
            <script type="text/javascript" charset="utf-8" src="cordova-2.3.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>
            <meta content="yes" name="apple-mobile-web-app-capable" />
            <meta content="index,follow" name="robots" />
            <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
            <link href="pics/iosIcon.png" rel="apple-touch-icon" />
            <meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
            <link href="css/style.css" rel="stylesheet" media="screen" type="text/css" />
            <script src="javascript/functions.js" type="text/javascript"></script>
        </head>
        <body>
            <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
        </body>
    </html>

我的任何其他包含可能会阻止警报?^^

更新

好的,我看看我是否排除了函数.js,它可以

var iWebkit;if(!iWebkit){iWebkit=window.onload=function(){function fullscreen(){var a=document.getElementsByTagName("a");for(var i=0;i<a.length;i++){if(a[i].className.match("noeffect")){}else{a[i].onclick=function(){window.location=this.getAttribute("href");return false}}}}function hideURLbar(){window.scrollTo(0,0.9)}iWebkit.init=function(){fullscreen();hideURLbar()};iWebkit.init()}}

最新更新