2012-02-19 57 views
0

我有一個問題,應該打開另一個頁面使用jQuery的特定部分的鏈接。 index.php文件的如何打開頁面的特定部分使用jquery

簡化視圖:

<?php 
if (!isset($a)) $a = ''; 
switch($a) 
{ 
case 1: 
default: 
print('<div class"left">the left menu that contains links to specific parts of the  page</div><div class="main">content of the page</div>'); 
break; 
case 2: 
echo "second part"; 
break; 
case 3: 
echo "third part"; 
break; 
} 
?> 

在這個頁面上我使用jQuery在「主」 DIV來打開這個文件的某些部分。 當我點擊左邊的鏈接時,使用jquery,我可以在「main」DIV中打開「第三部分」的內容; 本頁面的樣子:

-------------------- ---------------------------------- 
|     | |         | 
| the left menu that | |         | 
| contains links to | |   third part    | 
| specific parts of | |         | 
| the  page  | |         | 
-------------------- ---------------------------------- 

我需要的是jQuery代碼,將允許單擊位於其他一些網頁,將打開index.php文件與內容的部分鏈接,如圖上面的例子。

現在,我所能做的就是打開的index.php的部分,其中「trird部位」是

---------------------------------- 
|         | 
|         | 
|   third part    | 
|         | 
|         | 
---------------------------------- 

,但我無法打開左MENY,並在同一頁主DIV使用其他頁面的鏈接。我怎樣才能做到這一點?

我使用的是第二頁上

jQuery代碼是:

$('.prt').click(function() { 
var adr=$(this).attr('rel'); 
window.open(adr); 
}) 

HTML的鏈接:

<div class="prt" rel="index.php?a=3">link</div> 

感謝所有的建議&指針

回答

0

如果你只是想總是顯示菜單,然後將其從switch-case語句中刪除並放在頂部。

我想你不想使用window.open並打開你的網站右側cotainer目標網頁。

我建議動態這樣做:

$('#main').load('content_3.html'); // Sample! 
相關問題