会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
RubyPdf 的中文博客
专注PDF技术
博客园
首页
新随笔
订阅
管理
在博客页首添加搜索功能
把博客园的搜索设置移植到了页面顶端,这样让博客的搜索功能更加醒目。
同时整合了“Adsense for Search” 以及“Add related keyword links”(添加相关关键字链接,起到搜索提示的功能)。
下面是我使用的代码:
<
script
language
="JavaScript"
>
function
SearchGoogle(key,evt,site)
{
if
(evt.keyCode
==
13
||
evt.keyCode
==
0
||
evt.type
==
'
click
'
)
{
key.focus();
var
keystr
=
encodeURIComponent(key.value);
url
=
"
http://www.google.com/search?q=
"
;
url
=
url
+
keystr;
url
+=
"
&client=pub-7558339387099421&forid=1&ie=UTF-8&oe=UTF-8&safe=active&cof=GALT%3A%23008000%3BGL%3A1%3BDIV%3A%23336699%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3A0000FF%3BLC%3A0000FF%3BT%3A000000%3BGFNT%3A0000FF%3BGIMP%3A0000FF%3BFORID%3A1&hl=zh-CN&x=0&y=0&domains=
"
+
site
+
"
&sitesearch=
"
+
site;
window.location
=
url;
return
false
;
}
}
</
script
>
<
table
><
tr
><
td
>
<
input
style
="WIDTH: 130px"
type
="text"
name
="q"
id
="q"
onkeydown
="return SearchGoogle(document.getElementById('q'),event,'http://www.cnblogs.com/hardrock/')"
>
<
input
onclick
="SearchGoogle(document.getElementById('q'),event,'http://www.cnblogs.com/hardrock/')"
type
="button"
value
="搜索"
name
="sa"
>
</
td
><
td
>
<
script
type
="text/javascript"
>
<!--
google_ad_client
=
"
pub-7558339387099421
"
;
google_ad_format
=
"
350x30_sdo
"
;
google_link_target
=
2
;
google_color_bg
=
"
ffffff
"
;
google_color_link
=
"
black
"
;
google_encoding
=
"
UTF-8
"
;
//
-->
</
script
>
<
script
type
="text/javascript"
src
="http://pagead2.googlesyndication.com/pagead/show_ads.js"
>
</
script
>
</
td
></
tr
></
table
>
posted on
2008-01-26 14:22
RubyPDF
阅读(
906
) 评论(
1
)
编辑
收藏
举报
刷新页面
返回顶部