2012-02-03 55 views
2

想象我有2個HTML文件jQuery的通話功能

的index.html

<html> 
    <div id="content"></div> 
    <div id="footer"></div> 
    <script> 
     $("#content").load("productos.html"); 
     $("#footer").load("pie.html"); 
    </script> 
</html> 

productos_main.html

<html> 
... 
<div id="prod_fabricantes" class="optbar">fabricantes</div> 
<div id="prod_industria" class="optbar">industria</div> 
<div id="prod_header"></div> 
<div id="prod_mainframe"></div> 
... 
<script> 
$('#prod_fabricantes').live('click', function() { 
    document.title = '..:: TITLLE :: Productos :: Fabricantes'; 
    $("#prod_header,#prod_mainframe").empty(); 
    $("prod_header").text("Text for Fabricantes's section"); 
    $('#prod_mainframe').load("prod_fabricantes.html"); 

}); 
$('#prod_industria').live('click', function() { 
    document.title = '..:: TITLLE :: Productos :: Industria'; 
    $("#prod_header,#prod_mainframe").empty(); 
    $("prod_header").text("Text for Industria's section"); 
    $('#prod_mainframe').load("prod_industria.html"); 

}); 
</script> 
</html> 

pie.html

<html> 
<div id="map syte"> 
<table class="table_site"> 
<tr> 
<td id="st_fab" class="topsite">Fabricantes</td> 
<td id="st_ind" class="topsite">Industria</td> 
</tr> 
</table> 

<script> 
$('#st_fab').live('click', function(){ 
    $('#content').empty(); 
    document.title = '..:: DIELECSUR S.L :: Productos :: Fabricantes'; 
    $("#content").load("productos_main.html"); 
    $("#prod_header,#prod_mainframe").empty(); 
    $("prod_header").text("Text for Fabricantes's section"); 
    $('#prod_mainframe').load("prod_fabricantes.html"); 
}); 
$('#st_ind').live('click', function(){ 
    $('#content').empty(); 
    document.title = '..:: DIELECSUR S.L :: Productos :: Idustria'; 
    $("#content").load("productos_main.html"); 
    $("#prod_header,#prod_mainframe").empty(); 
    $("prod_header").text("Text for Industria's section"); 
    $('#prod_mainframe').load("prod_industria.html"); 
}); 
... 
</html> 

我有問題使用網站加載內容在頁腳部分的地圖。的onclick 事件頁腳選項 1.click上#st_fab 2.it將productos_main.html裝入#content格 3,如果將執行以下$('#st_fab').live('click', function() { ... });

錯誤

只加載productos_main.html功能爲#內容DIV

請幫助

回答

1

嘗試:

 

$("#content").load("productos.html", function() { 
    $("#footer").load("pie.html"); 
}); 
 
+0

太感謝你了。有用! – 2012-02-04 20:42:58

0

您曾嘗試把.load事件到功能和使用範圍內:

function mainFrameLoad(strHTMLFile){ 
    $(document).ready(function($){ 
     $('#prod_mainframe').load(strHTMLFile); 
    }); 
}