2012-06-04 51 views
0

另一個新手尋求幫助。強迫燈箱在父頁面中打開php JavaScript

我有一個Main_index.php頁面。多個div被加載到這個頁面,每個div都有一個「More」信息按鈕。每個div都是一個模板樣式,並使用mysql數據完成。

<div class="more"><a href="advert_details.php?advert_id=<?php print $advert_id?>"id="more<?php print $advert_id?>"><?php echo MORE ?></a></div> 

每個「更多」按鈕會在燈箱內創建一個新頁面「advert_details.php」。這又是一個模板樣式,並從mysql加載詳細信息。燈箱代碼位於Main_index.php中。

<script language="JavaScript" type="text/javascript"> 
$(document).ready(function() 
     { 
     $('a').filter(function() { 
     return this.id.match(/more[0-9]/); 
    }).fancybox({ 
     'overlayColor' : '#000', 
     'overlayOpacity' : 0.1, 
     'width' : 640, 
     'height' : 940, 
     'type' : 'iframe' 
    }); 
}); 
</script> 

如果「advert_details.php」頁面中的一個被搜索引擎發現,當你點擊搜索結果,燈箱在空白頁面打開。

有什麼我可以添加,強制在「main_index.php」頁面打開「advert_details.php」頁面,利用燈箱JavaScript和顯示主要網站頁面?

我希望我解釋得很好,如果沒有,請詢​​問更多細節。

感謝

彼得

回答

0

您可以設置將進行檢查,以包括在主頁上advert_details.php的URL參數。

喜歡的東西

if(isset($_GET['showDetails'])) { 
    include "advert_details.php"; 
} 
+0

謝謝你們的評論,but.The廣告詳情頁是沒有問題的,當你是main_index頁面上。問題是,當(例如)advert_details.php?advert_id = 170的鏈接,這只是打開advert_details頁面,並且該頁面是正確和完整的。問題是,我需要強制打開main_index頁面,然後用lightbox打開advert_details.php。 – user1434701

+0

我加入以下到main_index.php [代碼] $ _SESSION [ 'fromsite'] = '是'[/代碼] 而這advert_details.php [代碼]如果(isset($ _ SESSION [」 fromsite'])){ \t echo'is set'; \t} else { \t header('Location:http://www.mysite.com/main_index.php'); \t} [/ code] 當來自網站時,我得到「設置」。當來自谷歌我重定向到main_index.php。 有人可以幫我打電話給advert_details頁面嗎? – user1434701

+0

@ user1434701,我不明白你想要做什麼。谷歌與瀏覽您的網站的方式不同。你爲什麼以這種方式開發你的網站? – Starx