友声网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
开启左侧

Google Adsense公益广告的替代方法

[复制链接]
vikingr 发表于 2010-4-22 11:39 | 显示全部楼层 |阅读模式
<p>很多朋友的blog都放上了Google广告,但是Google广告在没有抓到合适内容时便会自动以公益广告替代,其实我们也可以把公益广告换成我们自己的广告。下面我来讲方法:</p><p>1.首先在网站所在空间里建立一个文件夹,名字随便取,比如google。</p><p>2.下载google_adsense_script.htm文件,这是Google Adsense在没有合适的广告时,会调用的用户文件,我把代码贴出来: </p><p>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;<br />&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd &quot;&gt;<br />&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;<br />&lt;head&gt;<br />&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;<br />&lt;title&gt;&lt;/title&gt;<br />&lt;script src=&quot;<a href="http://www.ys166.com/main/google/top.js">http://www.ys166.com/main/google/top.js</a>&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; //这里你是调用的js文件地址<br />&lt;/head&gt;<br />&lt;body style=&quot;background-color: transparent;&quot;&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</p><p>3.调用的js文件,我命名为top.js: </p><p>document.write(&quot;&lt;iframe src=http://www.ys166.com/main/google/top_banner.htm width=468 height=60 align=left frameborder=no border=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no&gt;&lt;/iframe&gt;&quot;)<br />这里我是用的iframe调用另一个htm文件(top_banner.htm),大家把它换成你自己的文件地址。</p><p>4.最关键的了,你自己的广告代码,写在top_banner.htm中: </p><p>&lt;html&gt;<br />&lt;head&gt;<br />&lt;meta http-equiv='Content-Type' content='text/html; charset=gb2312'&gt;<br />&lt;title&gt;ad&lt;/title&gt;<br />&lt;style type='text/css'&gt;<br />&lt;!&ndash;<br />body {<br />$nbsp$$nbsp$margin-left: 0px;<br />$nbsp$$nbsp$margin-top: 0px;<br />$nbsp$$nbsp$margin-right: 0px;<br />$nbsp$$nbsp$margin-bottom: 0px;<br />}<br />&ndash;&gt;<br />&lt;/style&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot; src=&quot;http://union.3721.com/ass/adv1_1.js?pid2=A_insome_122963&quot;&gt;&lt;/script&gt; $nbsp$$nbsp$//这里是你自己的广告代码$nbsp$$nbsp$<br />&lt;/body&gt;<br />&lt;/html&gt;</p><p>5.把以上三个文件修改好后,放到你建立的文件夹中。这里要注意的是,Google Adsense不能跨域调用,比如,你有两个域名,指向不同的空间,那么,这两个空间中就都得放上这三个文件,不同共同调用一处的文件。</p><p>6.登陆Google Adsense,在&ldquo;替代广告网址或颜色&ldquo;一栏中填上你的google_adsense_script.htm文件路径,保存然后更新你的google广告代码,把新代码贴到你的网页中,其实也就是多了这么一行: </p><p>&lt;script type=&quot;text/javascript&quot;&gt;&lt;!&ndash;<br />google_ad_client = &quot;pub-1112570485760501&quot;;<br />google_alternate_ad_url = &quot;<a href="http://www.ys166.com/main/google/google_adsense_script.htm">http://www.ys166.com/main/google/google_adsense_script.htm</a>&quot;; //这里是多出来的调用代码<br />google_ad_width = 468;<br />google_ad_height = 60;<br />google_ad_format = &quot;468&times;60_as&quot;;<br />google_ad_channel =&quot;&quot;;<br />google_color_border = &quot;999999&quot;;<br />google_color_bg = &quot;999999&quot;;<br />google_color_link = &quot;FFFFFF&quot;;<br />google_color_url = &quot;0033FF&quot;;<br />google_color_text = &quot;FFFFFF&quot;;<br />//&ndash;&gt;&lt;/script&gt;<br />&lt;script type=&quot;text/javascript&quot;<br /> src=&quot;<a href="http://pagead2.googlesyndication.com/pagead/show_ads.js">http://pagead2.googlesyndication.com/pagead/show_ads.js</a>&quot;&gt;<br />&lt;/script&gt;</p>

RSS|无图版|手机版|友声网 ( 鲁ICP备15020090号-1 )|网站地图 | 点击这里给我发消息 |

GMT+8, 2024-3-29 20:23 , Processed in 0.133023 second(s), 7 queries , MemCache On.

Powered by Discuz! X

© ys166.com

快速回复 返回顶部 返回列表