0

我正在使用 phonegap 在 android 中构建一个巨大的业务应用程序。我要做的就是创建一个类似于.net 概念的母版页,其中将放置我的所有脚本标签、页眉和页脚,以避免多次重写相同的代码。

我将在每一页上使用这个 .HTML 文件。我尝试了以下内容,但没有奏效。

主要 HTML

<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
<link href="css/jquery.mobile-1.3.1.min.css" rel="stylesheet" />
<link href="css/jquery.mobile.structure-1.3.1.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.mobile.theme-1.3.1.css" rel="stylesheet" type="text/css" />
<link href="css/MyPersonnelTheme.css" rel="stylesheet" />
<script src="scripts/modernizr-2.6.2.js"></script>
<script src="scripts/jquery-1.9.1.min.js"></script>
<script src="scripts/jquery.mobile-1.3.0.min.js"></script>
<script src="scripts/jquery.validate.js" type="text/javascript"></script>
<script src="scripts/CustomJS/Common.js" type="text/javascript"></script>
<script src="scripts/CustomJS/AdditionalNotes.js" type="text/javascript"></script>
</head>
<body>


    <div class="content-area">
    <form action="" method="post" id="abc" name="abc">

    <ul data-role="listview" data-inset="true" width="100%">
        <li data-role="fieldcontain"  width="100%">
                <object name="foo" type="text/html" data="Memo.html"></object>
        </li>
    </ul>

    <ul data-role="listview" data-inset="true">



        <div data-role="header" data-theme="c">

        <h1>Additional Notes</h1>

        </div>
    <table align="center">
        <tr align="center">
            <td align="center">
                <div id="contentProgress" style="display: none" border="1">
                    <div align="center">
                        <h4>
                            Synchronization in progress...</h4>
                    </div>
                    <div align="center">
                        <img id="spin" src="Images/wait.gif" /></div>
                </div>
            </td>
        </tr>
    </table>

        <li data-role="fieldcontain">
            <label for="Reply">
                Additional Notes</label>
            <textarea cols="100" id="Reply" name="Reply" rows="20"></textarea>
        </li>

        <li data-role="fieldcontain">
            <table width="25%">
               <tr>
                    <td>
                        <input type="submit" id="submit" value="SAVE" data-mini="true" />
                    </td>

                </tr>
            </table>
        </li>
    </ul>
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            RetrieveFromDB();
            CheckSessionTimeout();
        });

        $('#submit').click(function (e) {
            e.preventDefault();
            savedata();
        });

    </script>
    </div>

</div>


备忘录.html

<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
<link href="css/jquery.mobile-1.3.1.min.css" rel="stylesheet" />
<link href="css/jquery.mobile.structure-1.3.1.css" rel="stylesheet" type="text/css" />
<link href="css/jquery.mobile.theme-1.3.1.css" rel="stylesheet" type="text/css" />
<link href="css/MyPersonnelTheme.css" rel="stylesheet" />
<script src="scripts/modernizr-2.6.2.js"></script>
<script src="scripts/jquery-1.9.1.min.js"></script>
<script src="scripts/jquery.mobile-1.3.0.min.js"></script>
<script src="scripts/jquery.validate.js" type="text/javascript"></script>
<script src="scripts/CustomJS/Common.js" type="text/javascript"></script>
<script src="scripts/CustomJS/AdditionalNotes.js" type="text/javascript"></script>
<script type="text/javascript">
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        CheckOnlineOfflineStatus();
        SetImageOnlineOffline('#onlineOffline');
        document.addEventListener("online", onOnline, false);
        document.addEventListener("offline", onOffline, false);
    }

    function onOnline() {
        SetOnlineOfflineImageFromCSS("true");
    }

    function onOffline() { 
        SetOnlineOfflineImageFromCSS("false");
    }  
</script>
</head>


    <div class="header-custom">
        <a href="javascript:goToNextPage('index.html')"><span class="home-icon"></span></a>
        <a href="javascript:goToNextPage('index.html')"><span class="wrds-logo"></span></a>
        <a href="javascript:javascript:SetLogOut()"><span id="onlineOffline" class="user-icon-online"></span></a>
    </div>


</html>
4

1 回答 1

1

试试这个代码:

<head id="head">
 // you should import the Jquery.js
</head>
<script>
$(function(){
        var numItems = $('.include').length();
        if(numItems ==0 )
        $('#head').append('<script type="text/javascript" class="include" src="Include.js"></script>');
});
</script>

在 Include.js 你应该有这样的东西:

    $(function(){
             $('#head').append('<script src="scripts/modernizr-2.6.2.js"></script>');
             $('#head').append('<script src="scripts/jquery-1.9.1.min.js"></script>');
             $('#head').append('<script src="scripts/jquery.mobile-1.3.0.min.js"></script>');
             $('#head').append('<script src="scripts/jquery.validate.js" type="text/javascript"></script>');
             $('#head').append('<script src="scripts/CustomJS/Common.js" type="text/javascript"></script>');
             $('#head').append('<script src="scripts/CustomJS/AdditionalNotes.js" type="text/javascript"></script>');
  });
于 2013-06-11T11:16:00.717 回答