You are here: Reference > JavaScript > client-side > browser > methods > addSearchEngine (sidebar)

addSearchEngine method (sidebar)

Browser support:
Installs a Sherlock formatted search engine plugin into the browser application.
This method allows adding your custom search engine to the user search provider list.
Note that the Sherlock formatted search engine plugins are only supported by Firefox, while the OpenSearch description format are widely supported. Use the AddSearchProvider method instead of the addSearchEngine method.

Syntax:

object.addSearchEngine (engineURL, iconURL, message, suggestedCategory);
You can find the related objects in the Supported by objects section below.

Parameters:

engineURL
Required. String that specifies the URL of the search engine plugin (.src).
iconURL
Required. String that specifies the URL of the icon associated with the plugin.
message
Required. String that specifies the message to show when prompting the user for permission to install the plugin.
suggestedCategory
Required. Not used. Set to null.

Return value:

This method has no return value.

Example HTML code 1:

This example illustrates the use of the addSearchEngine method.
<head>
    <script type="text/javascript">
        function AddSearch () {
            if (window.sidebar) {        // Firefox
                window.sidebar.addSearchEngine ('http://example.com/searchEngine.src', 'http://example.com/searchEngine.ico', 'Example Search Engine', null);
            }
        }
   </script>
</head>
<body>
    <button onclick="AddSearch ()">Add search engine</button>
</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 ("/external/examples/common/xml/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