Adding SharePoint Site as a Search Provider in Internet Explorer

AddSearchProvider was introduced in Windows Internet Explorer 7.

This method opens a dialog box that enables the user to add the provider to their registry, and optionally set it as the default search provider. The maximum number of search providers that can be installed is 200.

The sUrl parameter allows http:, https:, or ftp: protocol schemes only. Additionally, the URL must be in a security zone that permits downloading.

Search providers must use the HTTP GET request method; the POST request method is not supported.

Syntax of “Provider.xml” must be of valid XML format. Be sure to encode all characters in the query string. Particularly, escaping “&” to “&”.

The query string must contain “q={searchTerms}” somewhere within the query string. When Internet Explorer 8 navigates to the provider to get search results, “{searchTerms}” will be replaced by the query string that the user typed into the Instant Search box.

To add SharePoint Search Site as a Search Provider in Internet Explorer such bing or google we have to user the below syntax

window.external.AddSearchProvider(sUrl)

Here sUrl is a string that specifies an absolute or relative URL to the OpenSearch Description file for the search provider.

The following code will add the search provider on click of the button

<INPUT TYPE=”button” VALUE=”SPRIDER Search Provider”   onClick=’window.external.AddSearchProvider(“/_layouts/15/SPRIDER/XML/SPRIDER_IE_Provider.xml”);’>

This can be advertised automatically by embedding this file on the master page or webpart zone with the help of CEWP as shown below

<link title=”My Provider Name” rel=”search” type=”application/opensearchdescription+xml” href=”(“/_layouts/15/SPRIDER/XML/SPRIDER_IE_Provider.xml”>

Sample OpenSearch Description file content

<?xml version=”1.0″ encoding=”UTF-8″?>

<OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearch/1.1/”&gt;

<ShortName>SPRIDER Search </ShortName>

<Description> SPRIDER Search provider for Internet Explorer</Description>

<InputEncoding>UTF-8</InputEncoding>

<Url type=”text/html” template=”http://sprider/Pages/results.aspx?k={searchTerms}”/>

<Url type=”application/x-suggestions+xml” template=”http:// sprider/_layouts/15/amat/SuggestionProvider.aspx?k={searchTerms}”/>

<Image height=”16″ width=”16″ type=”image/x-icon”>http://sprider/_layouts/15/SPRIDER/Images/spriderfavicon.ico</Image&gt;

</OpenSearchDescription>

Here I have used the customized Suggestion response page (SuggestionProvider.aspx) to send empty response message when no suggestions found.

Advertisements

About Joseph Velliah
As a SharePoint Developer my professional interests tend to be technical and SharePoint focused. I run a blog at "SP RIDER" where you can expect to read HOW TOs and scenarios that I run into during my day to day job. I hope my posts will give back a little to the community that is helped me.

Comments are closed.

%d bloggers like this: