浏览器的搜索框如何工作? [英] How do browsers' Search boxes work?

查看:83
本文介绍了浏览器的搜索框如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要精确地了解浏览器中搜索框的工作方式.我想用Mathematics的自定义搜索引擎替换诸如Wikipedia和Google之类的搜索内容.您可以在iGoogle中看到它们.所以:

I need to precisely know how the search boxes on the browsers work. I would like to replace the search things, such as Wikipedia and Google, with customised search engines here at Mathematics. You can see them in iGoogle. So:

如何将Google自定义搜索引擎添加到 浏览器的搜索框?

How can I add Google CSEs to the browsers' search boxes?

推荐答案

您可以为网站创建所谓的搜索提供程序".您的网站上应该有一个搜索页面,该页面接受搜索关键字作为URL中的查询字符串,例如

You can create so called "Search Providers" for your sites. You should have a search page on your site which accepts the search keywords as query string in your URL, like

  http://www.example.com/search?q=meaning+of+life

这也应该可以在Google自定义搜索中使用.

This should work work Google Custom Search as well.

您必须创建一个特殊的XML文件(例如,将其命名为SearchProvider.xml)并将其放在Web服务器上:

You'll have to create a special XML file (call it SearchProvider.xml, for example) and put it on your web server:

<?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>

然后,您需要在页面的页眉部分插入一个特殊的链接标记:

Then, you'll need to insert a special link tag in your page's header section:

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

您还可以在页面上插入一个链接,使您的用户可以将搜索提供程序添加到浏览器中:

You could also insert a link to your page, which allows your users to add the search provider to the browser:

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

这篇关于浏览器的搜索框如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆