在个人网站上使用Google Chrome的OmniBox [TAB]功能? [英] Making usage of Google Chrome's OmniBox [TAB] Feature for/on personal website?

查看:147
本文介绍了在个人网站上使用Google Chrome的OmniBox [TAB]功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我如何利用Chrome的Omnibox [TAB]功能来处理我的内容网站?

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

然而,Chrome Omnibox [TAB]功能的实现并不适用。

Can你帮我了吗?



我的OSD.xml代码:

 < OpenSearchDescription xmlns =http://a9.com/-/spec/opensearch/1.1/
xmlns:moz =http://www.mozilla.org/2006/browser/search/ >
< ShortName> MySite< / ShortName>
<说明>我的网站< /说明>
< InputEncoding> UTF-8< / InputEncoding>
< Image width =16height =16type =image / x-icon> http://MySite.com/favicon.ico< / Image>
< Url type =application / x-suggestions + jsonmethod =GET
template =http://ff.search.yahoo.com/gossip?output=fxjson&amp; command = {searchTerms}/>
< Url type =text / htmlmethod =POSTtemplate =http://MySite.com/query.php>
< Param name =sStringvalue ={searchTerms}/>
< / Url>
< Url type =application / x-suggestions + jsontemplate =suggestionURL/>
< moz:SearchForm> http://www.MySite.com< / moz:SearchForm>
< / OpenSearchDescription>

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

 < link rel =searchtype =application / opensearchdescription + xmltitle =MySitehref =/ opensearch.xml/> 


解决方案

在Google Chrome或IE7下使用OSD(OpenSearchDescription) / IE8并不像上面提到的那么难,或者这些浏览器不支持POST请求。



稍微调整一下,我发现了一个解决整个问题的方法

我的初始代码:

 < Url type = text / htmlmethod =POSTtemplate =http://MySite.com/query.php> 
< Param name =sStringvalue ={searchTerms}/>
< / Url>

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



这对FireFox来说是完美的,但在IE7 / IE8或谷歌浏览器上效果并不理想(我还没有使用Opera或Safari进行测试..)。






将代码更改为以下内容:

 < Url type =text / htmltemplate =http://MySite.com/query.php?string={searchTerms}>< / Url> 




  • method =POST元素使用实际的页面调用替换 /query.php /query.php?string = {searchTerms}

  • 删除现在不必要的< Param name =sStringvalue ={searchTerms}/ >



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



所有通话都直接进入查询页面,甚至最初是一个POST请求,现在可以在IE7 / IE8和Google Chrome上使用。



再次感谢adrianbanks为我提供了导致解决方案的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&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>

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

<link rel="search" type="application/opensearchdescription+xml" title="MySite" href="/opensearch.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!

这篇关于在个人网站上使用Google Chrome的OmniBox [TAB]功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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