自定义Google AdSense搜索广告

Posted by Hpyer on 2009-03-03, 星期二

  如果你用过Google 广告中的AdSense搜索广告功能,那么你肯定为其丑陋的样式而烦恼过。撰写本文,正是为了帮助那些意在将Google作为自己网站搜索引擎的朋友们更好的应用该功能所生成的代码。

  关于如何注册Google帐号或者注册Google AdSense的问题,这里就不多说了。

  首先,通过AdSense搜索广告的向导生成默认的代码。(因为代码太长,所以就不放上来了)

  其次,将其中不是 <form 和 <input 开头的语句都删除,剩下如下代码就是该功能的核心代码了(以下的一句都不能少!)。

<form method="get" action="http://www.google.com/custom" target="google_window">
 
<input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input>
<input type="submit" name="sa" value="Google 搜索" id="sbb"></input>
 
<input type="radio" name="sitesearch" value="" checked id="ss0"></input>
<input type="radio" name="sitesearch" value="hpyer.cn" id="ss1"></input>
 
<input type="hidden" name="domains" value="hpyer.cn"></input>
<input type="hidden" name="client" value="pub-2203312467469475"></input>
<input type="hidden" name="forid" value="1"></input>
<input type="hidden" name="ie" value="UTF-8"></input>
<input type="hidden" name="oe" value="UTF-8"></input>
<input type="hidden" name="safe" value="active"></input>
<input type="hidden" name="flav" value="0000"></input>
<input type="hidden" name="sig" value="RADBp7q4bLq3vs_p"></input>
<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:200;L:http://hpyer.cn/logo-200x50.png;S:http://hpyer.cn;FORID:1"></input>
<input type="hidden" name="hl" value="zh-CN"></input>
</form>

  再次,上面的代码你可能觉得还是挺别扭的,没关系,咱们再来处理一下就好了。

<form method="get" action="http://www.google.com/custom" target="google_window">
<!-- 这样的语句都是注释,不会显示 -->
关键字:
<input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input>
<input type="submit" name="sa" value="Google 搜索" id="sbb"></input>
<br />
<input type="radio" name="sitesearch" value="" checked id="ss0"></input>
<label for="ss0">互联网</label>
<input type="radio" name="sitesearch" value="hpyer.cn" id="ss1"></input>
<label for="ss1">hpyer.cn</label>
 
<!-- 以下的都是隐藏的元素,不会显示 -->
<input type="hidden" name="domains" value="hpyer.cn"></input>
<input type="hidden" name="client" value="pub-2203312467469475"></input>
<input type="hidden" name="forid" value="1"></input>
<input type="hidden" name="ie" value="UTF-8"></input>
<input type="hidden" name="oe" value="UTF-8"></input>
<input type="hidden" name="safe" value="active"></input>
<input type="hidden" name="flav" value="0000"></input>
<input type="hidden" name="sig" value="RADBp7q4bLq3vs_p"></input>
<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:200;L:http://hpyer.cn/logo-200x50.png;S:http://hpyer.cn;FORID:1"></input>
<input type="hidden" name="hl" value="zh-CN"></input>
<!-- 隐藏的元素到此为止。但是不要把下面的</form>给忘了! -->
</form>

  好了,这样一来,效果就出来了。说几点需要注意的地方:

  一、代码中所有的ID属性的值都是可以更改成你需要的值,不改也没关系,但是name属性的值绝对不可以改。

  二、type=”submit” 一行中的value属性的值可以更改,它就是那个按钮的上的字。

  三、必须将所有有 type=”hidden” 的行原封不动的复制过来。

  四、如果希望默认是在你的网站上搜索,那就将 type=”radio” 的那两行改成下面的样子

<input type="radio" name="sitesearch" value="" id="ss0"></input>
<input type="radio" name="sitesearch" value="hpyer.cn" id="ss1" checked></input>

  五、上面所写的都是本站的代码,不要复制过去就用噢,不然就等于帮我打广告了,呵呵~

  六、经过本人测试,如果有人点击搜索结果页中的广告,Google 同样也会记录。

相关日志

Did you enjoy this article? Share it or give it a bump!
1,666 Views

2 Comments on “自定义Google AdSense搜索广告”

  • 记忆 wrote on 2009-09-27, 02:46 Reply to this comment

    路过,帮你踩踩!

  • 格式"Format wrote on 2009-11-02, 13:46 Reply to this comment

    我是来体验这个插件的!

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

Welcome to Hpyer 的未知空间

  哈咯~很高兴您能在浩瀚的网络中找到本站,虽然本站只是个博客,但是它却不仅仅是一个博客。在这里你将会了解到一些网页制作方面的知识,同时也可以获得一些实用的程序源码。但愿您在这次短暂的访问中可以有所收获。【了解更多】 【联系 Hpyer

Search

Search posts by Google engine. FROM:    

Advertisement