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

发布于 2024-08-02 04:35:41 字数 1329 浏览 5 评论 0原文

我认为标题已经解释了这一切,但我还是要更深入地探讨我的问题:

如何在我的网站上使用 Chrome 的多功能框 [TAB] 功能?

由于许多用户要求我在网站上实现该功能,我对 OpenSearchDescription 进行了研究,并且在 FireFox 和 IE7/IE8 Searchbar 上的实现非常成功。

然而,该实现对于 Chrome Omnibox [TAB] 功能来说并不太有效。

你能帮我吗?

我的 OSD.xml 代码:

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>MySite</ShortName>
<Description>My Site</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://MySite.com/favicon.ico</Image>
<Url type="application/x-suggestions+json" method="GET"
     template="http://ff.search.yahoo.com/gossip?output=fxjson&amp;command={searchTerms}" />
<Url type="text/html" method="POST" template="http://MySite.com/query.php">
  <Param name="sString" value="{searchTerms}"/>
</Url>
<Url type="application/x-suggestions+json" template="suggestionURL"/>
<moz:SearchForm>http://www.MySite.com</moz:SearchForm>
</OpenSearchDescription>

这是我页面上 osd 文件的链接:

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

I think the title explains it all but I am going deeper into my question anyway:

How can I make use of the Chrome's Omnibox [TAB] feature for my website?

As many users requested me to implement that feature on the site, I did research on the OpenSearchDescription and was very successful in implementation with the FireFox and IE7/IE8 Searchbar.

Yet the implementation didn't quite work for the Chrome Omnibox [TAB] feature..

Can you help me with that?

My OSD.xml code:

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>MySite</ShortName>
<Description>My Site</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://MySite.com/favicon.ico</Image>
<Url type="application/x-suggestions+json" method="GET"
     template="http://ff.search.yahoo.com/gossip?output=fxjson&command={searchTerms}" />
<Url type="text/html" method="POST" template="http://MySite.com/query.php">
  <Param name="sString" value="{searchTerms}"/>
</Url>
<Url type="application/x-suggestions+json" template="suggestionURL"/>
<moz:SearchForm>http://www.MySite.com</moz:SearchForm>
</OpenSearchDescription>

And this is the link to the osd file on my page:

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

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

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

发布评论

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

评论(2

佞臣 2024-08-09 04:35:41

我已将您的内容与我自己网站上的 OpenSearchDescription 进行了比较,但我不明白为什么您的网站不起作用。唯一真正的区别是您使用 POST 进行搜索,而我使用 GET。根据this页面,IE7不支持POST请求,所以其他浏览器可能也支持不支持POST。

我网站上的这个肯定可以在 IE8、Chrome 3.0 和 FF 2.0+ 中运行。请自行比较它们,看看是否可以发现差异:opensearch.XML

I've compared what you have against the OpenSearchDescription on my own site and I cannot see why yours is not working. The only real difference is that you are using POST to search whereas I am using GET. According to this page, IE7 does not support POST requests, so it may be that other browsers also do not support POST.

The one on my site definitely works in IE8, Chrome 3.0 and FF 2.0+. Feel free to compare them yourself and see if you can spot a difference: opensearch.XML

放飞的风筝 2024-08-09 04:35:41

在 Google Chrome 或 IE7 / IE8 下获取 OSD (OpenSearchDescription) 工作并不像前面提到的那么困难,或者这些浏览器不支持 POST 请求。

经过一些调整,我找到了解决整个问题的方法。

我的初始代码:

<Url type="text/html" method="POST" template="http://MySite.com/query.php">
  <Param name="sString" value="{searchTerms}"/>
</Url>

此代码直接指向查询页面,并在我的 POST 请求上传递 sString 属性的值。

这在 FireFox 上运行得很好,但在 IE7/IE8 或 Google Chrome 上运行得不太好(我还没有用 Opera 或 Safari 进行测试..)。


将代码更改为以下部分:

<Url type="text/html" template="http://MySite.com/query.php?sString={searchTerms}"></Url>
  • 从元素中删除 method="POST"
  • /query.php 替换为实际的页面调用:< strong>/query.php?sString={searchTerms}
  • 删除现在不必要的“< /code>"

解决了我与这些浏览器不兼容的问题。

所有调用都直接前往查询页面,即使最初是 POST 请求,现在也可以在 IE7/IE8 和 Google Chrome 上运行。

再次感谢 adrianbanks 为我提供了您的 xml 文件,从而找到了解决方案!

Getting OSD (OpenSearchDescription) work under Google Chrome or IE7 / IE8 isn't as difficult as mentioned or that these browsers don't support POST requests.

With a little bit of tweaking, I found a workaround to the entire problem.

My initial code:

<Url type="text/html" method="POST" template="http://MySite.com/query.php">
  <Param name="sString" value="{searchTerms}"/>
</Url>

This code points directly to the query page and passes the value for the sString attribute on my POST request.

That works perfectly on FireFox but doesn't quite work well on IE7/IE8 or Google Chrome (I didn't test with Opera or Safari yet..).


Altering the code to the following piece:

<Url type="text/html" template="http://MySite.com/query.php?sString={searchTerms}"></Url>
  • Removing method="POST" from the element
  • Replacing /query.php with the actual page call: /query.php?sString={searchTerms}
  • Removing the now unnecessary "<Param name="sString" value="{searchTerms}"/>"

Resolved my problem of incompatibility with those browsers.

All calls are directly headed to the query page and even it initially was a POST request, it now work on both IE7/IE8 and Google Chrome.

Thanks again adrianbanks for providing me with your xml file which led to the solution!

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