hakeの日記

Windows環境でプログラミングの勉強をしています。

ブラウザのスタートページに検索欄をつくる

こちらの「ネットフロントのホームページに設定するといいかもしれないhtml」で紹介されているGoogleの検索欄をスタートページに入れる方法を参考に、自分が良く利用するサイトの検索欄のみのページを作成。


Googleはそのまま利用させてもらって、AmazonWikipediaはてなのページのhtmlソースをみて検索用のformタグを抜き出して作成。やってみて気がついたのですが、各サイト毎に文字コードが指定されていて異なった文字コードでhtmlファイルを作成すると検索語が文字化け?します。仕方が無いのでGoole&Wikipediaをスタートページに追加して、他はリンクで指定するようにしました。でも同じページで全部の検索欄を追加できたほうが便利なので何か方法があれば良いのですけどね。
文字コードは以下のとおり

ちなみに確認はNetFront、Opera7.55、w3mで行ったのですけど、operaだけhttp-equivにcharsetを指定しないと文字化けしました。自動判別をしてくれないのかhtmlの解釈が厳密なのか……


Google & Wikipedia(utf8)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<TITLE>Google & Wikipedia Search</TITLE>
</head>
<body bgcolor="#8888ee">

<form action="http://www.google.com/search" name=f>
Googleサーチ&nbsp;
<input maxLength=256 size=55 name=q value=""> 
<input name=hl type=hidden value=ja>
<input type=submit value="検索" name=btnG><br>
        <input type=radio name=lr value="">ウェブ全体から検索 
<input type=radio name=lr value=lang_ja checked>日本語のページを検索 
</form>
<hr>

<form action="http://ja.wikipedia.org/wiki/Search">
Wikipedia&nbsp;
<input id="searchInput" name="search" type="text" accesskey="f" value="" size=55>
<input type='submit' name="go" class="searchButton" id="searchGoButton" value="表示" >&nbsp;
<input type='submit' name="fulltext" class="searchButton" value="検索" >
</form>
<hr>

</body>
</html>

Amazon(ShiftJIS)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">

<TITLE>Amazon Search</TITLE>
</head>
<body>

<form method="post" action="http://www.amazon.co.jp/exec/obidos/search-handle-form/">
Amaoznサーチ&nbsp;
<select name=url>
<option value="index=blended" selected>すべての商品
<option value="index=books-jp">和書
<option value="index=books-us">洋書
<option value="index=electronics-jp">エレクトロニクス
<option value="index=electronics-jp&field-browse=3371341">コンピュータ
<option value="index=kitchen-jp">ホーム&キッチン
<option value="index=music-jp">ポピュラー音楽
<option value="index=classical-jp">クラシック
<option value="index=dvd-jp">DVD
<option value="index=vhs-jp">ビデオ
<option value="index=software-jp">ソフトウェア
<option value="index=videogames-jp">ゲーム
<option value="index=toys-jp">おもちゃ&amp;ホビー
<option value="index=sporting-goods-jp">スポーツ
</select>
<input type="hidden" name="size" value=10>
<input type="hidden" name="search-type" value="quick-search">
<input type="text" name="field-keywords" size="55">&nbsp;&nbsp;
<input type="submit" value="検索" name="Go" src="" border="0" width=21 height=22 align="border=0 align=absmiddle">
</form>
<hr>

</body>
</html>

はてな(eucJP)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">

<TITLE>Hatena Search</TITLE>
</head>
<body>

<!--
<form name="search" class="headsearch" method="get" action="http://search.hatena.ne.jp/search">
-->
<form name="search" class="headsearch" method="get" action="http://d.hatena.ne.jp/keyword">
はてなキーワードサーチ&nbsp;
<input type=text name="word" size=41 maxlength=2048 value="">
<input type=submit value="キーワード検索">
</form>
<hr>

</body>
</html>