數星期前從一些網站學到在 Blog 加上搜尋及翻譯功能,忘了是那些,抱歉!!
有網友想知道怎樣做,我就直接放一些程式碼上來吧。
首先是搜尋,
<form id="searchthis" action="http://tonyyu27.blogspot.com/search" style="display: inline;" method="get">
<input id="b-query" maxlength="255" name="q" size="15"/>
<input id="b-searchbtn" class="blue" value="Search" type="submit"/>
By Google (Show result in this Blog)
</form>
<form id="te_s" action="http://www.technorati.com/search.php" method="post">
<input id="te_search" maxlength="255" name="s" size="15" type="text"/>
<input value="Search" type="submit"/>
<input value="searchlet" name="sub" type="hidden"/>
<input value="http://tonyyu27.blogspot.com" name="from" type="hidden"/>
然後是翻譯,
<table border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="30"><a href="javascript:dotrans('zh-TW|zh-CN');" class="" title="简体中文"><img border="0" src="http://tonyyu27.googlepages.com/CN.png"/></a>
</td>
<td width="30"><a href="javascript:dotrans('zh|en');" class="" title="English (USA)"><img border="0" src="http://tonyyu27.googlepages.com/USA.png"/></a>
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
function dotrans(destLang) {
var srcUrl = location.href.toLowerCase();
srcUrl = ((srcUrl.indexOf('%7c')!=-1 )? unescape(srcUrl.replace(/\+/g, " ")):srcUrl);
if( srcUrl.indexOf('&langpair=') != -1 || srcUrl.indexOf('?langpair=')!=-1) {
var idx = srcUrl.indexOf('&amp;amp;amp;amp;amp;amp;u=');
if( idx == -1 ) return;
srcUrl= srcUrl.substring(idx+3);
}
srcUrl = 'http://translate.google.com/translate_p?hl=zh-TW&langpair='+destLang+'&u='+srcUrl;
location.href=srcUrl;
}
</script>
0 留言:
發佈留言