如何为您的网站添加 google chrome 多功能框搜索支持?

发布于 2024-12-07 20:26:58 字数 185 浏览 0 评论 0原文

当我在 Google Chrome 多功能框中输入某些 URL 时,我会看到其中的消息“按 TAB 键在 $URL 中搜索”。例如,有一些俄罗斯网站 habrahabr.ru 或 yandex.ru。当您按 TAB 时,您将能够在该网站中进行搜索,而不是在搜索引擎中进行搜索。 如何让我的网站能够做到这一点?也许,我需要在我的网站页面中编写一些特殊的代码?

When I enter some of URLs in Google Chrome omnibox, I see message in it "Press TAB to search in $URL". For example, there are some russian sites habrahabr.ru or yandex.ru. When you press TAB you'll be able to search in that site, not in your search engine.
How to make my site to be able for it? Maybe, I need to write some special code in my site pages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦中楼上月下 2024-12-14 20:26:58

Chrome 通常通过用户偏好来处理此问题。 (通过chrome://settings/searchEngines

但是,如果您想专门为您的用户实现此功能,则需要向您的网站添加 OSD(开放搜索描述)。

使用 Google Chrome 的 OmniBox [TAB ] 个人网站的功能?

然后,您将此 XML 文件添加到您网站的根目录,并在您的 标记中链接到它:

<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml" />

现在,您的访问者页面会自动将您网站的搜索信息放入 Chrome 的内部设置 (chrome://settings/searchEngines)。

OpenSearchDescription XML 格式示例

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Your website name (shorter = better)</ShortName>
<Description>
Description about your website search here
</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">your site favicon</Image>
<Url type="text/html" method="get" template="http://www.yoursite.com/search/?query={searchTerms}"/>
</OpenSearchDescription>

重要的部分是 项。 {searchTerms} 将替换为用户在多功能栏中搜索的内容。

以下是 OpenSearch 的链接,了解更多信息。

Chrome usually handles this through user preferences. (via chrome://settings/searchEngines)

However, if you'd like to implement this specifically for your users, you need to add a OSD (Open Search Description) to your site.

Making usage of Google Chrome's OmniBox [TAB] Feature for/on personal website?

You then add this XML file to the root of your site, and link to it in your <head> tag:

<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml" />

Now, visitors to your page will automatically have your site's search information placed into Chrome's internal settings at chrome://settings/searchEngines.

OpenSearchDescription XML Format Example

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Your website name (shorter = better)</ShortName>
<Description>
Description about your website search here
</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">your site favicon</Image>
<Url type="text/html" method="get" template="http://www.yoursite.com/search/?query={searchTerms}"/>
</OpenSearchDescription>

The important part is the <url> item. {searchTerms} will be replaced with what the user searches for in the omnibar.

Here's a link to OpenSearch for more information.

鸩远一方 2024-12-14 20:26:58

通过搜索建议实现多功能框支持

@element119 给出的答案非常完美,但这里有一个稍微调整的代码以支持搜索建议以及 Mozilla 支持。

请按照以下步骤为您的网站实施多功能框支持。

  1. 将以下代码另存为 search.xml
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <script/>
  <ShortName>Site Name</ShortName>
  <Description>Site Description (eg: Search sitename)</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">Favicon url</Image>
  <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&q={searchTerms}" />
  <Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
  <SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>
  1. search.xml 上传到网站的根目录。

  2. 将以下元标记添加到您网站的 标记

<link rel="search" href="http://www.yoursite.com/search.xml" type="application/opensearchdescription+xml" title="You site name"/>

确保将域名网址替换为您的域名。

Implementing omnibox support with search suggestions

The answer given by @element119 works perfect but here is a slightly tweaked code to support search suggestions as well as Mozilla Support.

Follow the steps below to implement omni box support for your site.

  1. Save the following code as search.xml
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <script/>
  <ShortName>Site Name</ShortName>
  <Description>Site Description (eg: Search sitename)</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">Favicon url</Image>
  <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&q={searchTerms}" />
  <Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
  <SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>
  1. Upload search.xml to the root of your site.

  2. Add the following meta tag to your site's <head> tag

<link rel="search" href="http://www.yoursite.com/search.xml" type="application/opensearchdescription+xml" title="You site name"/>

Make sure to replace the domain urls with your domain.

爱的十字路口 2024-12-14 20:26:58

Google Chrome 不再支持自动发现网站特定搜索

@googlechrome Twitter 帐户:
我们这样做是为了让新的网站搜索快捷方式不再自动添加到 Chrome 搜索栏中。我们这样做是为了帮助避免将人们可能不会使用的网站搜索建议弄乱。

此回复最初是提供的在评论中(信用 Olivier Lalonde),但我重新发布它,以便更容易找到(例如,当我最初是在寻找答案)。

Google Chrome no longer supports the autodiscovery of site specific search

@googlechrome twitter account:
We made it so new Site search shortcuts are no longer automatically added to the Chrome search bar. We did this to help avoid cluttering it with Site search suggestions that people may not be using.

This response was originally provided in a comment (credit Olivier Lalonde) but I'm reposting it so it's easier to find (e.g. I didn't see this comment when I was originally looking for answers).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文