当我在 google chrome URL 中写入“stackoverflow.com”或“bing.com”然后空格时,它会添加“search stackoverflow”或“search bing”。

那么我们需要在我们的网络应用程序中实现什么才能让谷歌浏览器做到这一点?

注意:我发现 stackoverflow 和 bing 作为搜索引擎添加。我没有添加它。所以必须是一种要求将其从网络应用程序添加为搜索引擎的方法。

最佳答案

您需要为您的网站创建 opensearch xml 文档,然后通过您的页面 link head

例如,这是为 stackoverflow 设计的方式:

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

**OpenSearch xml **
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
    <script/>
    <ShortName>Stack Overflow</ShortName>
    <Description>
Search Stack Overflow: Q&A for professional and enthusiast programmers
    </Description>
    <InputEncoding>UTF-8</InputEncoding>
    <Image width="16" height="16" type="image/x-icon">
https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d
    </Image>
    <Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"/>
</OpenSearchDescription>

您可以使用 Youtube、Github 等热门搜索存储库查看更多示例。
另请参阅此 chromium tab-to-search 项目以获取更多详细信息。

关于google-chrome - 如何从地址栏搜索网站,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50869494/

10-12 21:35
查看更多