手把手教你在cnBlogs中加上自己的漂浮广告
现在很流行在自己的blog中加广告,尤其是google Adsense居多,虽然收入微乎其微,但是大家还是了此不疲。园子中很多朋友也都在自己的领地中加了一些,但是形势都非常呆板,主要原因是受其位置的限制,我自己研究了一下,整理了一个漂浮上去,效果还蛮不错,特与大家分享,效果如下(当然直接到我的Blog也能看到效果http://liudao.cnblogs.com)
具体设置步骤如下:后台管理—〉博客设置:页首Html代码 中加入以下代码:
<script type="text/javascript">
//<![CDATA[
var tips; var theTop = 200/*这是默认高度,越大越往下*/; var old = theTop;
function initFloatTips() {
tips = document.getElementById('floatTips');
moveTips();
};
//51aspx.com
function moveTips() {
var tt=50;
if (window.innerHeight) {
pos = window.pageYOffset
}
else if (document.documentElement && document.documentElement.scrollTop) {
pos = document.documentElement.scrollTop
}
else if (document.body) {
pos = document.body.scrollTop;
}
pos=pos-tips.offsetTop+theTop;
pos=tips.offsetTop+pos/10;
if (pos < theTop) pos = theTop;
if (pos != old) {
tips.style.top = pos+"px";
tt=10;
}
old = pos;
setTimeout(moveTips,tt);
}
//!]]>
</script>
<style type="text/css">
div#floatTips{
position:absolute;
top:250px;
left:500px;
width:300px;
border:dotted #B9ECAE 1px;
border-right:dotted #B9ECAE 0px;
}
</style>
</head>
<body onload="initFloatTips()">
<div id="floatTips">
<!--以下是广告内容(51aspx.com)-->
<script type="text/javascript"><!--
google_ad_client = "pub-5440286391851514";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
//2007-08-27: cnblogs漂浮
google_ad_channel = "3789594809";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "339900";
google_color_text = "339900";
google_color_url = "008000";
google_ui_features = "rc:10";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
//<![CDATA[
var tips; var theTop = 200/*这是默认高度,越大越往下*/; var old = theTop;
function initFloatTips() {
tips = document.getElementById('floatTips');
moveTips();
};
//51aspx.com
function moveTips() {
var tt=50;
if (window.innerHeight) {
pos = window.pageYOffset
}
else if (document.documentElement && document.documentElement.scrollTop) {
pos = document.documentElement.scrollTop
}
else if (document.body) {
pos = document.body.scrollTop;
}
pos=pos-tips.offsetTop+theTop;
pos=tips.offsetTop+pos/10;
if (pos < theTop) pos = theTop;
if (pos != old) {
tips.style.top = pos+"px";
tt=10;
}
old = pos;
setTimeout(moveTips,tt);
}
//!]]>
</script>
<style type="text/css">
div#floatTips{
position:absolute;
top:250px;
left:500px;
width:300px;
border:dotted #B9ECAE 1px;
border-right:dotted #B9ECAE 0px;
}
</style>
</head>
<body onload="initFloatTips()">
<div id="floatTips">
<!--以下是广告内容(51aspx.com)-->
<script type="text/javascript"><!--
google_ad_client = "pub-5440286391851514";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
//2007-08-27: cnblogs漂浮
google_ad_channel = "3789594809";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "339900";
google_color_text = "339900";
google_color_url = "008000";
google_ui_features = "rc:10";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
试试看,效果还不错吧,以后不用每次发文的时候再单独插入广告了,这个是按照51aspx.com 的样式进行设计的,当然你也可以进行扩展,希望对你有所帮助。要注意广告不要加的太过分哦,否则会影响dudu的adsense收入阿!
按照常理此方法也应该同样适用于其他Blog,51aspx还没来得及测试~~
该文首发于liudao的blog(http://liudao.cnblogs.com),转载请注明出处!
liudao-MVP