使用HTML页面包含页面时,jQuery无法正常工作

时间:2012-06-16 09:51:58

标签: jquery css jsp

参考this question

我们有一个带有日期选择组件的标题(Jquery和css)。当单独存在标题时,日期选择器工作正常。当我尝试将另一个页面作为具有此标题的正文包含时,日期选择器不起作用。

我们正在使用this link

中提到的日期选择器

当我们在上述代码中包含其他页面时,选择的日期不起作用。

包含我使用的命令。 <%@ include file="enterClarity.jsp" %> 在enterCalrity.jsp页面中有一些表单验证java脚本

编辑:

单独使用标题

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/calendar.css" type="text/css" />
<link rel="stylesheet" href="../css/datepicker_comp_1.css" type="text/css"/>
<link rel="stylesheet" href="../css/datepicker_comp_2.css" type="text/css"/>
<script type="text/javascript" src="../js/datepickr.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript" charset="utf-8">
 jQuery(function(){
  jQuery("#datepicker").datepicker();
 });
</script>
<title>Clarity</title>
</head>

<body>

<form id="clarityaction" name="tstest" onsubmit="return true;" action="/metrix/clarityaction.action" method="post"><table class="wwFormTable">
        <table width="100%" border="0" style="height: 616px; width: 1260px;"
            cellpadding="0" cellspacing="0">
            <tr class="header">
                <td align="right" valign="bottom">
                <B>Welcome Karthik Prabhu D </B>
                </td>
            </tr>
            <tr class="header">
                <td align="right" valign="top">your last login was : 2012-06-16 15:33:51.0
                </td>
            </tr>
            <tr align="left" valign="bottom"><td>
            <input type="text" id="datepicker" class="haspicker" /></td></tr>



            <tr>
                <td bgcolor="#FFFFFF" height="70%" width="100%">
                    <table width="60%" border="0" style="height: 430px; width: 1206px;"
                        cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <table border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <table border="0"style="vertical-align: top" cellpadding="0" cellspacing="0">

                                                <tr>
                                                    <td>

                                                    </td>
                                                </tr>
                                            </table></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                </table>
                            </td>

                        </tr>
                    </table></td>
            </tr>

            <tr>

                <td class="footer"></td>
            </tr>

        </table>


    </table></form>





</body>

</html>

包含页面后:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/calendar.css" type="text/css" />
<link rel="stylesheet" href="../css/datepicker_comp_1.css" type="text/css"/>
<link rel="stylesheet" href="../css/datepicker_comp_2.css" type="text/css"/>
<script type="text/javascript" src="../js/datepickr.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript" charset="utf-8">
 jQuery(function(){
  jQuery("#datepicker").datepicker();
 });
</script>
<title>Clarity</title>
</head>

<body>

<form id="clarityaction" name="tstest" onsubmit="return true;" action="/metrix/clarityaction.action" method="post"><table class="wwFormTable">
        <table width="100%" border="0" style="height: 616px; width: 1260px;"
            cellpadding="0" cellspacing="0">
            <tr class="header">
                <td align="right" valign="bottom">
                <B>Welcome Karthik Prabhu D </B>
                </td>
            </tr>
            <tr class="header">
                <td align="right" valign="top">your last login was : 2012-06-16 15:36:10.0
                </td>
            </tr>
            <tr align="left" valign="bottom"><td>
            <input type="text" id="datepicker" class="haspicker" /></td></tr>



            <tr>
                <td bgcolor="#FFFFFF" height="70%" width="100%">
                    <table width="60%" border="0" style="height: 430px; width: 1206px;"
                        cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <table border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <table border="0"style="vertical-align: top" cellpadding="0" cellspacing="0">

                                                <tr>
                                                    <td>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"  src="../js/tabing.js"></script>
<script type="text/javascript" src="../js/tabjs.js"></script>
<script type="text/javascript" src="../js/validaionjs.js"></script>
<link rel="stylesheet" href="../css/tabStyle.css" type="text/css" />
</head>
<body>

<-- Other page contents -->         

</body>

</html>

1 个答案:

答案 0 :(得分:0)

根据您发布的代码,第二个完整的html文件被注入另一个。你有一个html页面在另一个...绝对不好;)

    !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="../css/calendar.css" type="text/css" />
    <link rel="stylesheet" href="../css/datepicker_comp_1.css" type="text/css"/>
    <link rel="stylesheet" href="../css/datepicker_comp_2.css" type="text/css"/>
    <script type="text/javascript" src="../js/datepickr.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
    <script type="text/javascript" charset="utf-8">
     jQuery(function(){
      jQuery("#datepicker").datepicker();
     });
    </script>
    <title>Clarity</title>
    </head>

    <body>

    <form id="clarityaction" name="tstest" onsubmit="return true;" action="/metrix/clarityaction.action" method="post"><table class="wwFormTable">
            <table width="100%" border="0" style="height: 616px; width: 1260px;"
                cellpadding="0" cellspacing="0">
[...]    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript"  src="../js/tabing.js"></script>
    <script type="text/javascript" src="../js/tabjs.js"></script>
    <script type="text/javascript" src="../js/validaionjs.js"></script>
    <link rel="stylesheet" href="../css/tabStyle.css" type="text/css" />
    </head>
    <body>

    <-- Other page contents -->