You are here: Reference > JavaScript > client-side > browser > methods > AddSearchProvider (external, sidebar)

AddSearchProvider method (external, sidebar)

Browser support:
7
Installs a search engine plugin into the browser application.
This method allows adding your custom search engine to the user search provider list. Supported in Internet Explorer from version 7.

Syntax:

object.AddSearchProvider (URL);
You can find the related objects in the Supported by objects section below.

Parameters:

URL
Required. The location of the search provider's XML file. The URL must be absolute (it must contain both the protocol (such as http:) and the domain) in Firefox and Google Chrome, The XML file should be in OpenSearch description format.

Return value:

This method has no return value.

Example HTML code 1:

This example shows how to tell the client's browser that you offer a search plugin from HTML. If the search provider is currently installed it will be the selected search engine.
Code
searchProvider.xml
<head>
    <link rel="search" type="application/opensearchdescription+xml"
            href="searchProvider.xml" title="Dottoro Search" /> 
</head>
<body>
    Please open the drop-down menu of your browser's Search Box.
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the AddSearchProvider method.
Code
searchProvider.xml
<head>
    <script type="text/javascript">
        function AddSearch () {
            if (window.external && ('AddSearchProvider' in window.external)) {
                window.external.AddSearchProvider ("searchProvider.xml");
            }
            else {
                alert ("Your browser does not support the AddSearchProvider method!");
            }
        }
   </script>
</head>
<body>
    <button onclick="AddSearch ()">Add search engine</button>
    <br /><br />
    To manage search engines, open the drop-down menu of your browser's Search Box (Firefox and Internet Explorer)
    or select Options/Basics/Default Search/Manage (Google Chrome).
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content