终于在公告栏里加进啦Google自定义搜索引擎(附代码,和参考代码,原代码)

252 篇文章 0 订阅

现在Me公告栏里使用的代码

code: new_0.0.2

< script  language ="javascript" >
function on_search_click(){
 Form1.action 
= "http://www.google.com/custom?q=";
 Form1.target 
= "_blank";
 Form1.method 
= "get";
}

</ script >
<!--  Search Google  -->
< center >
< table  bgcolor ="#ffffff" >
< tr >< td  nowrap ="nowrap"  valign ="top"  align ="left"  height ="32" >

< br />
< input  type ="text"  name ="q"  size ="23"  maxlength ="255"  value ="" ></ input >
</ td ></ tr >
< tr >< td  valign ="top"  align ="left" >
< input  type ="submit"  name ="sa"  value ="Google 搜索"  onclick ="javascript:on_search_click()" ></ input >
< input  type ="hidden"  name ="client"  value ="pub-3938365705781251" ></ input >
< input  type ="hidden"  name ="forid"  value ="1" ></ input >
< input  type ="hidden"  name ="channel"  value ="0968900262" ></ input >
< input  type ="hidden"  name ="ie"  value ="utf-8" ></ input >
< input  type ="hidden"  name ="oe"  value ="GB2312" ></ input >
< input  type ="hidden"  name ="flav"  value ="0001" ></ input >
< input  type ="hidden"  name ="sig"  value ="191Qey090PRjYYr6" ></ 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:114;L:http://www.google.com/logos/Logo_60wht.gif;S:http://blog.csdn.net/clin003;FORID:1" ></ input >
< input  type ="hidden"  name ="hl"  value ="zh-CN" ></ input >
</ td ></ tr ></ table >
</ form >
</ center >
<!--  Search Google  -->


 

 

参考文章代码:给自己的Blog 上添加定制的搜索引擎

http://blog.csdn.net/smile2me27/archive/2004/07/08/37008.aspx

 

< script  language ="javascript" >
function on_search_click(){
 Form1.action 
= "http://www.google.com/custom/";
 Form1.target 
= "_blank";
 Form1.method 
= "get";
}

</ script >
<!--  Search Google  -->
< center >
< table  cellspacing ="0"  border ="0" >
< tr >< td > Google 查询: </ td ></ tr >
< tr  valign ="top" >< td >
< input  type ="text"  name ="q"  maxlength ="255"  value =""  style ="width:130px;border:3px double #cecece;" >
< input  type ="submit"  name ="sa"  value ="Search"  onclick ="javascript:on_search_click()" >
< input  type ="hidden"  name ="cof"  value ="AH:center;AWFID:3182aae82da4ddf8;" >
< input  type ="hidden"  name ="ie"  value ="GB2312" >
< input  type ="hidden"  name ="oe"  value ="GB2312" >
< input  type ="hidden"  name ="domains"  value ="blog.csdn.net" >< br >
< input  type ="radio"  name ="sitesearch"  value ="" >  By WWW 
< input  type ="radio"  name ="sitesearch"  value ="blog.csdn.net"  checked ="checked" >  By Me 
</ td ></ tr ></ table >
</ center >
<!--  Search Google  -->  
< br >


 

code: new_0.0.1

 



<!--  Search Google  -->

< div  style ="text-align: left;" >

< script  type ="text/javascript" >
function searchGoogle(key,evt,site)
{
if(evt.keyCode==13 || evt.keyCode==0 || evt.type =='click')
{
key.focus();
var keystr = key.value;
url 
= "http://www.google.com/custom?q=";
url 
= url + keystr;
url 
+= "&sa=Google+%E6%90%9C%E7%B4%A2&client=pub-3938365705781251&forid=1&channel=0968900262&ie=GB2312&oe=GB2312&flav=0001&sig=191Qey090PRjYYr6&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3AFFFFFF%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BLH%3A50%3BLW%3A114%3BL%3Ahttp%3A%2F%2Fwww.google.com%2Flogos%2FLogo_60wht.gif%3BS%3Ahttp%3A%2F%2Fblog.csdn.net%2Fclin003%3BFORID%3A1&hl=zh-CN";
window.location
=url;
return false;
}

}

</ script >

< input  style ="width: 130px"  type ="text"  name ="q"  size ="23"  maxlength ="255"  id ="q"  

onkeydown
="return SearchGoogle(document.getElementById

('q'),event,'blog.csdn.net/clin003/')"
  /> &nbsp;

< table  bgcolor ="#ffffff" >
< tr >< td  nowrap ="nowrap"  valign ="top"  align ="left"  height ="32" >
</ td ></ tr >
< tr >< td  valign ="top"  align ="left" >
< input   onclick ="searchGoogle(document.getElementById

('q'),event,'blog.csdn.net/clin003/')"
 type ="button"
                        value
="Google 搜索"  name ="sa"   />

</ td ></ tr ></ table >
</ div >

<!--  Search Google  -->

 

由于可以在 url 变量里 直接加上自定义google搜索参数,就省啦下面这大段代码

 


< input  type ="hidden"  name ="client"  value ="pub-3938365705781251" ></>
< input  type ="hidden"  name ="forid"  value ="1" ></>
< input  type ="hidden"  name ="channel"  value ="0968900262" ></>
< input  type ="hidden"  name ="ie"  value ="GB2312" ></>
< input  type ="hidden"  name ="oe"  value ="GB2312" ></>
< input  type ="hidden"  name ="flav"  value ="0001" ></>
< input  type ="hidden"  name ="sig"  value ="191Qey090PRjYYr6" ></>
< 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:114;L:http://www.google.com/logos/Logo_60wht.gif;S:http://blog.csdn.net/clin003;FORID:1" ></>
< input  type ="hidden"  name ="hl"  value ="zh-CN" ></>

 

如果想使用google主站的风格,可以把他的“参数”抄过来,

我的公告栏里的代码参考自:http://blog.csdn.net/blogdevteam/archive/2006/05/29/760124.aspx

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

< div  style ="text-align: left;" >

< script  type ="text/javascript" >
function searchGoogle(key,evt,site)
{
if(evt.keyCode==13 || evt.keyCode==0 || evt.type =='click')
{
key.focus();
var keystr = key.value;
url 
= "http://www.google.com/search?q=";
url 
= url + keystr;
url 
+= "&ie=UTF-8&oe=GB2312&hl=zh-CN&domains="+site+"&sitesearch="+site;
window.location
=url;
return false;
}

}

</ script >

< input  style ="width: 130px"  type ="text"  name ="q"  id ="q"  onkeydown ="return SearchGoogle(document.getElementById('q'),event,'blog.csdn.net')"   /> &nbsp;

< input   onclick ="searchGoogle(document.getElementById('q'),event,'blog.csdn.net')"  type ="button"
                        value
="搜索"  name ="sa"   />
</ div >


 

原来google提供的代码搜索没反应,开发小组称:

经查证,该问题是asp.net的server端form导致的,解决此问题请使用如上代码:

 

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

原本google提供的代码是如下:

 

<!--  Search Google  -->
< center >
< form  method ="get"  action ="http://www.google.cn/custom"  target ="google_window" >
< table  bgcolor ="#ffffff" >
< tr >< td  nowrap ="nowrap"  valign ="top"  align ="left"  height ="32" >

< br />
< input  type ="text"  name ="q"  size ="23"  maxlength ="255"  value ="" ></ input >
</ td ></ tr >
< tr >< td  valign ="top"  align ="left" >
< input  type ="submit"  name ="sa"  value ="Google 搜索" ></ input >
< input  type ="hidden"  name ="client"  value ="pub-3938365705781251" ></ input >
< input  type ="hidden"  name ="forid"  value ="1" ></ input >
< input  type ="hidden"  name ="channel"  value ="0968900262" ></ input >
< input  type ="hidden"  name ="ie"  value ="GB2312" ></ input >
< input  type ="hidden"  name ="oe"  value ="GB2312" ></ input >
< input  type ="hidden"  name ="flav"  value ="0001" ></ input >
< input  type ="hidden"  name ="sig"  value ="191Qey090PRjYYr6" ></ 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:114;L:http://www.google.com/logos/Logo_60wht.gif;S:http://blog.csdn.net/clin003;FORID:1" ></ input >
< input  type ="hidden"  name ="hl"  value ="zh-CN" ></ input >
</ td ></ tr ></ table >
</ form >
</ center >
<!--  Search Google  -->

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值