当前位置:首页 > Union > 正文内容

Google Adsense公益广告的替代方法

admin2007-10-28Union960

很多朋友的blog都放上了Google广告,但是Google广告在没有抓到合适内容时便会自动以公益广告替代,其实我们也可以把公益广告换成我们自己的广告。下面我来讲方法:

1.首先在网站所在空间里建立一个文件夹,名字随便取,比如google。

2.下载google_adsense_script.htm文件,这是Google Adsense在没有合适的广告时,会调用的用户文件,我把代码贴出来:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<script src="http://hi.ys166.com/main/google/top.js" type="text/javascript"></script> //这里你是调用的js文件地址
</head>
<body style="background-color: transparent;">
</body>
</html>

3.调用的js文件,我命名为top.js:

document.write("<iframe src=http://hi.ys166.com/main/google/top_banner.htm width=468 height=60 align=left frameborder=no border=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no></iframe>")
这里我是用的iframe调用另一个htm文件(top_banner.htm),大家把它换成你自己的文件地址。

4.最关键的了,你自己的广告代码,写在top_banner.htm中:

<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
<title>ad</title>
<style type='text/css'>
<!–
body {
$nbsp$$nbsp$margin-left: 0px;
$nbsp$$nbsp$margin-top: 0px;
$nbsp$$nbsp$margin-right: 0px;
$nbsp$$nbsp$margin-bottom: 0px;
}
–>
</style>
</head>
<body>
<script language="JavaScript" type="text/JavaScript" src="http://union.3721.com/ass/adv1_1.js?pid2=A_insome_122963"></script> $nbsp$$nbsp$//这里是你自己的广告代码$nbsp$$nbsp$
</body>
</html>

5.把以上三个文件修改好后,放到你建立的文件夹中。这里要注意的是,Google Adsense不能跨域调用,比如,你有两个域名,指向不同的空间,那么,这两个空间中就都得放上这三个文件,不同共同调用一处的文件。

6.登陆Google Adsense,在“替代广告网址或颜色“一栏中填上你的google_adsense_script.htm文件路径,保存然后更新你的google广告代码,把新代码贴到你的网页中,其实也就是多了这么一行:

<script type="text/javascript"><!–
google_ad_client = "pub-1112570485760501";
google_alternate_ad_url = "http://hi.ys166.com/main/google/google_adsense_script.htm"; //这里是多出来的调用代码
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468×60_as";
google_ad_channel ="";
google_color_border = "999999";
google_color_bg = "999999";
google_color_link = "FFFFFF";
google_color_url = "0033FF";
google_color_text = "FFFFFF";
//–></script>
<script type="text/javascript"
 src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

打赏

扫描二维码推送至手机访问。

版权声明:本文由友声网博客发布,如需转载请注明出处。

本文链接:https://hi.ys166.com/t/41

分享给朋友:

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。