我正在尝试通过使用opensearch在我的网站URL上实现Tab搜索。我遵循了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在此处输入图像描述

发布于 2021-01-20 23:04:47
结构是正确的,问题是您忘记在模板中添加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时,它将会起作用。它仍然会在搜索中使用好的端口。这是因为搜索关键字没有端口。
https://stackoverflow.com/questions/65773991
复制相似问题