Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
您可以为您的网站创建所谓的“搜索提供程序”。 您的网站上应该有一个搜索页面,它接受搜索关键字作为 URL 中的查询字符串,例如“
这也应该适用于 Google 自定义搜索”。
您必须创建一个特殊的 XML 文件(例如,将其称为
SearchProvider.xml
)并将其放在您的 Web 服务器上:然后,您需要在页面的标题部分:
您还可以插入指向页面的链接,该链接允许您的用户将搜索提供程序添加到浏览器:
You can create so called "Search Providers" for your sites. You should have a search page on your site which accepts the search keywords as query string in your URL, like
This should work work Google Custom Search as well.
You'll have to create a special XML file (call it
SearchProvider.xml
, for example) and put it on your web server:Then, you'll need to insert a special link tag in your page's header section:
You could also insert a link to your page, which allows your users to add the search provider to the browser:
浏览器搜索框是通过称为 OpenSearch 的技术实现的。 请参阅:http://www.opensearch.org/(网站目前已关闭?)
Mozilla 有一个很好的页面其中解释了如何为其浏览器实现此功能: https://developer.mozilla.org/en/Creating_OpenSearch_plugins_for_Firefox< /a> 虽然其中有一些 Mozilla 特定的详细信息,但该页面可以作为跨浏览器实现的良好起点。
向搜索框添加自动完成功能有点棘手。 首先按照 Mozilla 的描述添加自动完成查询 URL。 然后,您必须在服务器上制作符合各种浏览器期望的响应。
看看 Google 针对其支持的不同浏览器返回的结果:
Browser search boxes are implemented in a technology called OpenSearch. See: http://www.opensearch.org/ (site currently down?)
Mozilla has a good page which explains how to implement this for their browsers: https://developer.mozilla.org/en/Creating_OpenSearch_plugins_for_Firefox While there are a few Mozilla-specific details there, that page can serve as a good starting point for cross-browser implementation.
Add auto-complete to the search box is a bit trickier. First add the auto-complete query URL as described by Mozilla. Then you must craft a response on your server which conforms to what the various browsers expect.
Take a look at what Google returns for the different browsers they support:
它可能取决于浏览器,但对于 Firefox,自定义它很简单:请参阅搜索栏和如何轻松地将自定义搜索引擎添加到您的 Firefox 搜索栏。
It probably depends on the browser to browser, but with Firefox, it's simple to customize it: see Search Bar and How To Easily Add A Custom Search Engine To Your Firefox Search Bar.
Microsoft 提供了一个向 IE 添加自定义搜索提供程序的工具,并且“添加到搜索栏”扩展允许您对 Firefox 执行相同的操作。
Microsoft provide a tool to add custom search providers to IE, and the Add to Search Bar extension allows you to do the same with Firefox.