【问题标题】:How to implement chromium openSearch?如何实现铬 openSearch?
【发布时间】:2021-04-22 17:16:02
【问题描述】:

我正在尝试使用 opensearch 在我的网站 URL 上实现 Tab To Search。我按照 openSearch 文档中的步骤操作,但仍然没有为我工作。请帮我弄清楚我错过了什么。

我的 XML 文件:

<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
 <ShortName>localhost</ShortName>
 <Description>Search localhost</Description>
 <Url type="text/html" method="get" template="localhost:8080/?query={searchTerms}"/>
</OpenSearchDescription>

而我在 index.html 文件中的 Head 标签是:

<!doctype html>
<html>
<head>
    <link rel="search"
          type="application/opensearchdescription+xml"
          title="Google IFL"
          href="tabToSearch.xml">
 </head>

结果:每当我按下 Tab 按钮时,它都会跳转到下一个 url 在此处输入图像描述

【问题讨论】:

    标签: html xml chromium opensearch


    【解决方案1】:

    结构是正确的,问题是您忘记在模板中添加http协议。 如果没有协议,它不会被添加到 chrome 中。

    -  <Url type="text/html" method="get" template="localhost:8080/?query={searchTerms}"/>
    +  <Url type="text/html" method="get" template="http://localhost:8080/?query={searchTerms}"/>
    

    执行此操作后,您将能够在 Chrome 自定义搜索引擎设置中看到它。

    但是,当您尝试搜索 localhost 而不是 localhost:8080 时,它会起作用。它仍将使用良好的端口进行搜索。这是因为搜索关键字没有端口。

    【讨论】:

    • 嗨@abkarino,感谢您的回复,实际上我尝试按照您建议的方式添加http协议,但即使使用localhost关键字仍然无法正常工作。还有其他提示吗?
    • 检查是否在设置中找到该条目。另外我建议您尝试使用任何本地域和端口 80 进行测试。 http://luna.local。只需将它放在 hosts 文件中指向 127.0.0.1,我可以向你保证它会工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 2023-03-06
    • 2022-01-22
    • 2022-01-05
    • 1970-01-01
    • 2022-08-24
    • 2012-01-28
    相关资源
    最近更新 更多