2010-11-11 44 views
0

我正在使用jQuery的load函數將包含Google廣告的頁面加載到另一個頁面。jQuery.load()不會顯示Google廣告

但Google廣告即使在我打開網頁時也不會顯示。

我該怎麼辦?

編輯:

一些代碼:

功能負荷的PHP頁面:

function get_fb(g) { 

$("#hhs").load("hhs.php?rid="+g); 

} 

和hhs.php包含谷歌廣告代碼...

+0

發表一些代碼! – 2010-11-11 21:50:31

+0

可能的重複http://stackoverflow.com/questions/435391/refresh-a-div-that-has-a-google-ad-inside-it – 2010-11-11 22:01:54

回答

1

廣告通常被嵌入通過腳本標記和$(...).load()刪除任何腳本標記:

// inject the contents of the document in, removing the scripts 
// to avoid any 'Permission Denied' errors in IE 
.append(res.responseText.replace(rscript, "")) 

rscript是一個正則表達式匹配script標籤:/<script(.|\s)*?\/script>/gi

然而,AdSense for Ajax可能是你所需要的。

+0

是的,但我不認爲谷歌將接受我的申請與20.000每月的看法。 – 2010-11-11 22:11:43

+0

您在這種情況下運氣不佳。最好的解決方案是將廣告放置在未動態重新加載的主頁的靜態部分。 – ThiefMaster 2010-11-11 22:14:55

+0

這不僅僅是jQuery,通過'innerHTML'插入'