WEB制作のメモ帳

ホームページにGoogleの検索ボックスを設置する

2011-06-05

その他

ホームページにGoogleの検索ボックスを設置する

ブログやポータルサイト等で見かけるサイト内検索窓。
サイト専用に用意をするとDBの開発が必要だったりとかなり大変ですが、DBを利用しなくても簡単なgoogle検索窓をホームページ内に設置する方法を見つけたのでメモ。

SOURCE
■HTML

<center>
<form method=get action="http://www.google.co.jp/search">
<table bgcolor="#FFFFFF"><tr><td>
<a href="http://www.google.co.jp/">
<img src="http://www.google.com/logos/Logo_40wht.gif"
border="0" alt="Google" align="absmiddle"></a>
<input type=text name=q size=31 maxlength=255 value="">
<input type=hidden name=ie value=UTF-8>
<input type=hidden name=oe value=UTF-8>
<input type=hidden name=hl value="ja">
<input type=submit name=btnG value="Google 検索">
</td></tr></table>
</form>
</center>

サイト内検索の場合
<center>
<form method=get action="http://www.google.co.jp/search">
<table bgcolor="#FFFFFF"><tr valign=top><td>
<a href="http://www.google.co.jp/">
<img src="http://www.google.com/logos/Logo_40wht.gif"
border="0" alt="Google" align="absmiddle"></a>
</td>
<td>
<input type=text name=q size=31 maxlength=255 value="">
<input type=hidden name=ie value=UTF-8>
<input type=hidden name=oe value=UTF-8>
<input type=hidden name=hl value="ja">
<input type=submit name=btnG value="Google 検索">
<font size=-1>
<input type=hidden name=domains value="サイトドメイン"><br>
<input type=radio name=sitesearch value=""> WWW を検索
<input type=radio name=sitesearch value="サイトドメイン" checked> サイトドメインを検索
</font>
</td></tr></table>
</form>
</center>

※利用サイトの文字コードがUTF-8ではない場合、コード内 2箇所のUTF-8を適した文字コードに変更する。
参考サイト
Google検索機能を追加
http://www.google.co.jp/intl/ja/searchcode.html