-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