hhh*_*hhh 1 google-custom-search
我需要准确地知道浏览器上的搜索框是如何工作的.我想用数学中的自定义搜索引擎替换搜索内容,例如维基百科和谷歌.您可以在iGoogle中看到它们.所以:
如何将Google CSE添加到浏览器的搜索框中?
您可以为您的站点创建所谓的"搜索提供商".您的网站上应该有一个搜索页面,它接受搜索关键字作为您网址中的查询字符串,例如
http://www.example.com/search?q=meaning+of+life
Run Code Online (Sandbox Code Playgroud)
这应该适用于Google自定义搜索.
您必须创建一个特殊的XML文件(SearchProvider.xml
例如,调用它)并将其放在您的Web服务器上:
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Example Search Provider</ShortName>
<Description>Finds answers to the most important question of the universe</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" template=" http://www.example.com/search?q={searchTerms}"/>
</OpenSearchDescription>
Run Code Online (Sandbox Code Playgroud)
然后,您需要在页面的标题部分插入一个特殊的链接标记:
<link title="Example Search Provider" rel="search"
type="application/opensearchdescription+xml"
href="http://www.example.com/SearchProvider.xml" />
Run Code Online (Sandbox Code Playgroud)
您还可以插入指向您页面的链接,以便用户将搜索提供程序添加到浏览器:
<a href="#"
onclick="javascript:window.external.AddSearchProvider('http://www.example.com/SearchProvider.xml');">
Example Search Provider</a>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1652 次 |
最近记录: |