2010-11-11 63 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'插入'