Implement opensearch in three steps

Source: Internet
Author: User

After the opensearch function is added to the website, browsers with ie 7.0 and Firefox 2.0 or above (well, I admit that this function is not found in opera and chrome, but ie 8.0 RC and Firefox 3.05 are absolutely no problem) You can add the search function of this website in the built-in search bar.

To add the opensearch function, there are three steps:

Step 1: implement the opensearch function;

Step 2: Compile the opensearch description file;

Step 3: Add a reference to the opensearch description file.

Then, let's start:

Step 1: implement the opensearch function.

This is the simplest one. If there is a search, you just need to make it support the get parameter transfer.

Assume that you are searching for "ABCD" on the website now, the actual page address is http://example.com /? Q = ABCD

Step 2: Compile the opensearch description file.

You only need to add an XML file to the website. The content is as follows:

1 <? XML version = "1.0" encoding = "UTF-8"?>
2 <opensearchdescription xmlns = "http://a9.com/-/spec/opensearch/1.1/">
3 <shortname> Web Search </shortname>
4 <description> Use example.com to search the Web. </description>
5 <tags> Example Web </tags>
6 <contact> admin@example.com </contact>
7 <URL type = "text/html"
8 template = "http://example.com /? Q = {searchterms} "/>
9 </opensearchdescription>

For ease of description, name the file opensearch. xml and place it in the root directory of the website.

Step 3: Add a reference to the opensearch description file.

This step is also very simple. You only need to add a sentence to the

<Link type = "application/opensearchdescription + XML"
Href = "opensearch. xml" Title = "Web Search" rel = "Search"/>

That's all.

More:

You can provide more settings by modifying the opensearch description file.

Firefox supports the use of the opensearch suggestions plug-in for word-by-word search. To implement this function, you only need to return formatted JSON Data Based on search parameters, and then add the corresponding URL parameters to the description file.

IE support (Firefox also supports) Use opensearch referrer plug-in to add referrer parameters for search.

References:

Opensearch 1.1 protocol

Opensearch Homepage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.