ブラウザの検索ボックスがどのように機能するのですか? [閉まっている]

StackOverflow https://stackoverflow.com/questions/1058275

  •  21-08-2019
  •  | 
  •  

質問

私は正確には、ブラウザの検索ボックスがどのように機能するかを知っておく必要があります。私はここで数学でカスタマイズされた検索エンジンでは、そのようなウィキペディアやGoogleなどの検索物事を、交換したいと思います。あなたはiGoogleの中でそれらを見ることができます。だから、ます:

  

はどのように、Googleのカスタム検索エンジンのを追加することができます   ブラウザの検索ボックス?

役に立ちましたか?

解決

あなたはあなたのサイトのためのいわゆる「検索プロバイダ」を作成することができます。あなたは、

のように、あなたのURLにクエリ文字列などの検索キーワードを受け入れるサイトの検索ページを持っている必要があります
  http://www.example.com/search?q=meaning+of+life

これは、同様の作業Googleカスタム検索を動作するはずです。

あなたは特別なXMLファイルを作成する必要があります(例えば、SearchProvider.xmlそれを呼び出す)と、Webサーバー上に置くでしょう。

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
   <ShortName>Example Search Provider</ShortName>
   <Description>Finds answers to the most important question of the universe</Description>
   <InputEncoding>UTF-8</InputEncoding>
   <Url type="text/html" template=" http://www.example.com/search?q={searchTerms}"/>
</OpenSearchDescription>

次に、あなたがあなたのページのヘッダ部分に特殊なリンクタグを挿入する必要があります:

 <link title="Example Search Provider" rel="search"
     type="application/opensearchdescription+xml"
     href="http://www.example.com/SearchProvider.xml" />

また、あなたのユーザーがブラウザに検索プロバイダを追加することができますあなたのページへのリンクを挿入できます:

<a href="#"
   onclick="javascript:window.external.AddSearchProvider('http://www.example.com/SearchProvider.xml');">
Example Search Provider</a>

他のヒント

ブラウザの検索ボックスは、OpenSearchのと呼ばれる技術で実装されています。参照してください: http://www.opensearch.org/ の(?現在、サイトダウン)

ます。https://開発

Mozillaは、ブラウザのためにこれを実装する方法を説明します良いページを持っています。いくつかのMozilla固有の詳細がありますがmozilla.org/en/Creating_OpenSearch_plugins_for_Firefox に、そのページには、クロスブラウザの実装のための良い出発点となることができます。

追加オートコンプリートの検索ボックスには少しトリッキーです。 Mozillaが説明したように、第1オートコンプリートクエリのURLを追加します。そして、あなたは様々なブラウザが期待するものに準拠して、サーバー上の応答を作る必要があります。

Googleは、彼らがサポートする別のブラウザに対して返す何を見てみましょう

* Firefox: http://suggestqueries.google.com/complete/search?client=firefox&hl=en-US&q=xmarks
      o Content-Type: text/javascript
      o Response body: ["xmarks",["xmarksthaspot","xmarksthescot","foxmarks safari","xmark.com","gmarks firefox","x marks foxmarks","xmarksthespot","xmarks ie","foxmarks addon","foxmarks for ie"]] 
* Safari: http://suggestqueries.google.com/complete/search?client=safari&hl=en-US&q=xmarks
      o Content-Type: application/json
      o Response body: ["xmarks",[["xmarksthaspot","18,400 results","0"],["xmarksthescot","196,000 results","1"],["foxmarks safari","148,000 results","2s"],["xmark.com","336,000 results","3s"],["gmarks firefox","50,700 results","4s"],["x marks foxmarks","13,500 results","5s"],["xmarksthespot","20,500 results","6"],["xmarks ie","96,400 results","7"],["foxmarks addon","210,000 results","8s"],["foxmarks for ie","191,000 results","9s"]]]
* Others: http://suggestqueries.google.com/complete/search?client=ie&hl=en-US&q=xmarks
      o Content-Type: text/javascript
      o Response body: I'm not sure it's relevant. It's essentially the exact same format as Safari above, but it's wrapped by a JavaScript call to window.google.ac.h(). I'm not 100% certain, but that looks like the callback to their HTML-page version of auto-completion and suggests to me that they don't really support opensearch auto-completion in anything but Firefox and Safari.

これはおそらく、ブラウザに、ブラウザに依存しますが、Firefoxで、それをカスタマイズするために簡単です:検索バーを表示し、どのように簡単にあなたのFirefoxの検索バーにカスタム検索エンジンを追加するには、

MicrosoftがIEにカスタム検索プロバイダを追加するためのツールを提供し、バーの拡張子を検索するための追加]を使用すると、Firefoxで同じことを行うことができます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top