PhoneGap Javascript除在索引文件中外不工作

PhoneGap Javascript除在索引文件中外不工作,javascript,jquery-mobile,cordova,Javascript,Jquery Mobile,Cordova,嗨,我正在尝试运行一个javascript函数来测试一个警报,但是当它位于index.html以外的页面时,它不会触发 下面是一个页面示例,该页面未触发javascript警报注释,该注释已从所有标记中删除,以便在堆栈溢出中呈现: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, m

嗨,我正在尝试运行一个javascript函数来测试一个警报,但是当它位于index.html以外的页面时,它不会触发


下面是一个页面示例,该页面未触发javascript警报注释,该注释已从所有标记中删除,以便在堆栈溢出中呈现:

<!DOCTYPE html>
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <script type="text/javascript" charset="utf-8" src="phonegap-1.0.0.js"></script>
        <script type="text/javascript" charset="utf-8">
            document.addEventListener("deviceready", onDeviceReady, false);

            // PhoneGap is loaded and it is now safe to make calls PhoneGap methods
            //
            function onDeviceReady() {
            document.addEventListener("deviceready", onDeviceReady, false);
            }


            function onDeviceReady() {
            alert("test");
            navigator.notification.alert("PhoneGap is working");
            }

        </script>

        <link rel="stylesheet"  href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" />
        <link rel="stylesheet" href="docs/_assets/css/jqm-docs.css" />
        <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
        <script src="experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
        <script src="docs/_assets/js/jqm-docs.js"></script>
        <script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>
        <link rel="stylesheet" href="n_style.css" />

    </head>
    <body onload="onBodyLoad()">


    </body>
</html>

onDeviceReady仅在应用程序启动时触发一次。见文件:


该函数表示PhoneGap已完全加载。

onDeviceReady仅在应用程序启动时触发一次。见文件:


该函数表示PhoneGap已完全加载。

您的Javascript没有运行,因为您没有onBodyLoad函数。我会包装文档。addEventListenerdeviceready,onDeviceReady,false;在车载功能中。此外,如果您有javascript错误,请尝试在firefox中打开页面并使用firebug检查错误。

您的javascript没有运行,因为您没有onBodyLoad函数。我会包装文档。addEventListenerdeviceready,onDeviceReady,false;在车载功能中。另外,如果您有javascript错误,请尝试在firefox中打开页面,并使用firebug检查错误。

<从所有标记中删除,以便在堆栈溢出中呈现<从所有标记中删除,以便在堆栈溢出中呈现