-1
我有一个页面,每页有大约50篇博客文章。每篇博客文章的内容都隐藏着CSS,并在用户点击博客文章标题时显示。当用户点击标题时,是否有办法将AdSense内容动态添加到每篇博文中? Google允许吗?使用Adsense添加动态广告
我知道我可以在页面上添加50个广告,并用css隐藏它们,直到用户点击博客标题,但效率非常低。
这是林试图做:
例子:
HTML:
<div id="post1">
<h1>Blog Post 1</h1>
<p class="hidden">This is the content for blog post.</p>
</div>
CSS:
body {
padding:30px;
}
* {
font-family:arial;
}
h1 {
font-weight:bold;
cursor:pointer;
font-size:20px;
}
p.hidden {
display:none;
}
div.ad {
float:right;
background-color:red;
height:100px;
width:100px;
color:#ffffff;
font-weight:bold;
font-size:11px;
text-align:center;
}
脚本:
$("h1").click(function() {
var thisid = $(this).parent().attr("id");
if ($("div#"+thisid+ " p").hasClass("hidden")) {
$("div#"+thisid+ " p.hidden").removeClass("hidden");
// insert dymanic adsense ad
$("div#"+thisid+ " p").before('<div class="ad">insert dynamic adsense ad here!</div>');
} else {
$("div#"+thisid+" p").addClass("hidden");
$("div#"+thisid+" div.ad").remove();
}
});
所以,你有什么似乎正在工作的代码...你遇到问题?你在问什么? – cdeszaq 2012-01-30 18:28:02
我的问题是有没有办法动态地添加AdSense内容到每个博客文章? Google允许吗? – supercoolville 2012-01-30 18:30:20