主页面包含了两段javascript函数,一个是在div的ID为header的位置用jquery加载页面头,一个是在div的ID为topmenucontainer的位置加载导航菜单。<head>
<script type="text/javascript">$(document).ready(function() {
$("div#header").load("/header.html");
}); menu.init({
contentsource: ["topmenucontainer", "topmenu.html"] //"up" or ["container_id","path_to_menu_file"]
});</script>
</head><body>
<table width="800" height="120" border="0" align="center" cellpadding="0" cellspacing="0">  <tr>
        <td align="left" width="800" height="80" valign="top">
<div id="header"></div>
</td>
  </tr>  <tr>
        <td align="left" valign="top" width="800" height="40">
<div id="topmenucontainer"></div>
        </td>
  </tr>
    
</table>
</body>header.html的代码如下:  <html>
  <body>
  <img src="images/header.jpg" width="800" height="80" alt="" />
  </body>
  </html>
但是最后在浏览器里只能看到header被加载,导航菜单却是没有。如果注释掉加载header的jquery语句,导航菜单是能够显示在正常位置的。求解,thanks~!

解决方案 »

  1.   

    <script type="text/javascript">$(document).ready(function() {
    $("div#header").load("/header.html");
    menu.init({
    contentsource: ["topmenucontainer", "topmenu.html"] //"up" or ["container_id","path_to_menu_file"]
    });

    });  </script>
    </head>
      

  2.   


    $(document).ready(function() {
    $("div#header").load("/header.html");
    menu.init({
    contentsource: ["topmenucontainer", "topmenu.html"] });});  
      

  3.   

    补充一下:menu.init 包含在外部js文件menu.js中,head头作了一个外部引用;<script type="text/javascript" src="js/menu.js">