注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

写着玩

Bob

 
 
 

日志

 
 
 
 

Tab to Search  

2010-01-10 22:34:12|  分类: Chrome |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
Among the many features Chromium's Omnibox offers is the ability to search a site without navigating to the sites homepage. Once Chromium has determined it can search a site, any time the user types the URL of the site into the Omnibox the user is offered the ability to search the site. Once the user presses tab, then types in a string and presses the enter, the site is searched and the results shown to the user. It's important to note the search is done by the site itself, not Google or Chromium.

Chromium provides two heuristics that automatically add a site to the list of searchable sites. The following describes these heuristics:

1. On your sites homepage provide a link to an OpenSearch description document. The link to the OSDD is placed in the head of the html file. For example:
<head>
 <link type="application/opensearchdescription+xml" rel="search"
       href="url_of_osdd_file"/>
</head>
The important part of this document is the URL used to search your site. The following is an example that contains the bare minimum needed, see theOpenSearch description document specification for the list of values you can specify.
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
 <ShortName>Search My Site</ShortName>
 <Description>Search My Site</Description>
 <Url type="text/html" method="get" template="http://my_site/{searchTerms}"/>
</OpenSearchDescription>
When the user presses enter in the Omnibox the string {searchTerms} in the url is replaced with the string the user typed.

You can also include a suggestion service by adding another URL element with rel="suggestions" such as: 
  <Url type="application/json" rel="suggestions" template="http://my_site/suggest?q={searchTerms}" />
If you include this, the omnibox will use your suggestion service to provide query suggestions based on the user's partial query.

2. If the site does not provide a link to an OpenSearch description document but the user submits a form, then Chrome automatically adds the site to the list of searchable sites. There are a number of restrictions with this approach though. In particular the form must generate a GET, must result in a HTTP url, and the form must not have OnSubmit script. Additionally there must be only one input element of type text, no passwords, files or text areas and all other input elements must be in their default state.

For 1 and 2 Chromium only adds sites that the user navigated to without a path. For example http://mysite.com, but not http://mysite.com/foo.

Additionally a page can use the script function AddSearchProvider to add the site. The call takes an OpenSearch description document as described in 1.
  评论这张
 
阅读(205)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017