0

嗨,我的 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>

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

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>

这不起作用并使我的孔检查崩溃“所有都已检查”任何人都可以提供帮助吗?

4

2 回答 2

0

它在这里工作:

<!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>

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

更新

好吧,我看看我是否排除了它工作的function.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()}}
于 2013-01-17T11:34:03.100 回答
0
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 Nein der andere Code sollte da nichts blocken。

于 2013-01-17T11:37:34.543 回答