无法在“新”JSP页面上加载脚本和图像

时间:2012-07-12 09:38:58

标签: javascript jquery html5 jsp jquery-mobile

加载新的.jsp页面时会出现

问题。问题在于它没有像主题所说的那样加载脚本或图片。

我的index.jsp

<html>
<head> 
    <title>My Page</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="js/jquery.mobile-1.1.0.css" />
    <script type="text/javascript" src="js/dataManager.js"></script>
    <script type="text/javascript" src="js/MenuLoader.js"></script>
    <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="js/jquery.mobile-1.1.0.js"></script>
</head> 
<body> 


    <!-- Start of first page -->
    <div data-role="page" id="first">

        <div data-role="header">
            <a href="#" data-rel="back" data-role="button" ><img align="middle"src="images/back.png" alt="beskeder" vspace="2"/></a> 
            <h1><img onclick="getStuff('/product/5')" align="middle"src="images/main_header.png" alt="beskeder" vspace="2"/></h1>
        </div><!-- /header -->

        <div data-role="content" id="firstPageContent"> 
            <p>I'm first in the source order so I'm shown as the page.</p>      
            <p>View internal page called <a href="#second">second</a></p>
            <a href="pages/mapMode.jsp" id="mapLink" name="mapLink"><img id="mapLinkImage" alt="a map which links to the mapPage" src="images/beskeder.png"/></a>
            <Button text="menuLoader.load" id="loadButton" name="loadButton" onClick="load()">menuLoader.load</button>
            <Button text="dataManager.addPicture" name="addPictureButton" id="addPictureButton" onClick="addPicture('firstPageContent')">dataManager.addPicture</button>
            <Button text="dataManager.reset" name="reset" id="reset" onClick="resetPageContent('firstPageContent')">dataManager.resetPageContent</button>
        </div><!-- /content -->

        <div data-role="footer">
            <h4>Page Footer</h4>

        </div><!-- /footer -->
    </div><!-- /page -->
</body>
</html>

当我按下mapLink按钮,然后我点击了所需的jsp页面,但它只是没有加载任何图片,并且按钮onclick功能不起作用。

这是mapMode.jsp的代码(几乎与index.jsp相同):

<html>
    <head> 
        <title>My Page</title> 
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <link rel="stylesheet" href="js/jquery.mobile-1.1.0.css" />
        <script type="text/javascript" src="js/dataManager.js"></script>
        <script type="text/javascript" src="js/MenuLoader.js"></script>
        <script type="text/javascript" src="js/jquery-1.7.2.js"></script>
        <script type="text/javascript" src="js/jquery.mobile-1.1.0.js"></script>
    </head> 
    <body> 


        <!-- Start of first page -->
        <div data-role="page" id="mapmode">

            <div data-role="header">
                <a href="#" data-rel="back" data-role="button" ><img align="middle"src="images/back.png" alt="back" vspace="2"/></a> 
                <h1><img onclick="getStuff('/product/5')" align="middle"src="images/main_header.png" alt="logo" vspace="2"/></h1>
            </div><!-- /header -->

            <div data-role="content" id="mapmodePageContent">   
                <p>I'm the first page in mapMode!.</p>      
                <Button text="dataManager.addPicture" name="addPictureButton" id="addPictureButton" onClick="addPicture('mapmodePageContent')">dataManager.addPicture</button>
                <Button text="dataManager.reset" name="reset" id="reset" onClick="resetPageContent('firstPageContent')">dataManager.resetPageContent</button>
            </div><!-- /content -->

            <div data-role="footer">
                <h4>Page Footer</h4>

            </div><!-- /footer -->
        </div><!-- /page -->
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

如果你把你的js放在一个子文件夹中,记得在你的图片位置前面添加“../”...愚蠢的我