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

编程知识 更新时间:2023-05-03 04:06:51

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

code: new_0.0.2

< script  language ="javascript" > ...
function on_search_click()...{
 Form1.action 
= "http://www.google/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/logos/Logo_60wht.gif;S:http://blog.csdn/clin003;FORID:1" ></ input >
< input  type ="hidden"  name ="hl"  value ="zh-CN" ></ input >
</ td ></ tr ></ table >
</ form >
</ center >
<!--  Search Google  -->


 

 

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

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

 

< script  language ="javascript" > ...
function on_search_click()...{
 Form1.action 
= "http://www.google/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" >< br >
< input  type ="radio"  name ="sitesearch"  value ="" >  By WWW 
< input  type ="radio"  name ="sitesearch"  value ="blog.csdn"  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/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%2Flogos%2FLogo_60wht.gif%3BS%3Ahttp%3A%2F%2Fblog.csdn%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/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/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/logos/Logo_60wht.gif;S:http://blog.csdn/clin003;FORID:1" ></>
< input  type ="hidden"  name ="hl"  value ="zh-CN" ></>

 

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

我的公告栏里的代码参考自:http://blog.csdn/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/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')"   /> &nbsp;

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


 

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

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

 

 

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

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

 

<!--  Search Google  -->
< center >
< form  method ="get"  action ="http://www.google/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/logos/Logo_60wht.gif;S:http://blog.csdn/clin003;FORID:1" ></ input >
< input  type ="hidden"  name ="hl"  value ="zh-CN" ></ input >
</ td ></ tr ></ table >
</ form >
</ center >
<!--  Search Google  -->

 

 

更多推荐

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

本文发布于:2023-04-30 12:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/1c7c5216a28efddd630ad998fa4bc5c2.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   自定义   栏里   原代码   搜索引擎

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 114547文章数
  • 28958阅读数
  • 0评论数