mozilla

Revision 93133 of Adding search engines from web pages

  • Revision slug: Adding_search_engines_from_web_pages
  • Revision title: Adding search engines from web pages
  • Revision id: 93133
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Removed opensearch link, which is about to go away

Revision Content

Firefox allows JavaScript code to install search engine plugins, and supports three search engine plugin formats: OpenSearch, MozSearch, and Sherlock.

When JavaScript code attempts to install a search plugin, Firefox presents an alert asking the user for permission to install the plugin.

Installing OpenSearch and MozSearch plugins

To install either an OpenSearch or a MozSearch plugin, you need to use the window.external.AddSearchProvider() DOM method. The syntax for this method is:

window.external.AddSearchProvider(engineURL);

Where engineURL is the URL to the XML file for the search engine plugin.

Note: OpenSearch and MozSearch support is available only in Firefox 2 and later.

For details on MozSearch, see Creating MozSearch plugins.

Installing Sherlock plugins

To install a Sherlock plugin, you need to call window.sidebar.addSearchEngine(), the syntax for which is:

window.sidebar.addSearchEngine(engineURL, iconURL, suggestedName, suggestedCategory);
  • The engineURL parameter is the URL to the Sherlock plugin (a ".src" file) to install.
  • iconURL is the URL to an icon to associate with the plugin.
  • The suggestedName parameter is only used when prompting the user for permission to install the plugin, so that a message such as "Do you want to install suggestedName from engineURL?" can be displayed.
  • The suggestedCategory parameter is not used. You should specify either an empty string ("") or null.

For details on Sherlock, visit http://developer.apple.com/macosx/sherlock/

{{ wiki.languages( { "ja": "ja/Adding_search_engines_from_web_pages" } ) }}

Revision Source

<p>Firefox allows JavaScript code to install search engine plugins, and supports three search engine plugin formats: OpenSearch, MozSearch, and Sherlock.
</p><p>When JavaScript code attempts to install a search plugin, Firefox presents an alert asking the user for permission to install the plugin.
</p>
<h2 name="Installing_OpenSearch_and_MozSearch_plugins">Installing OpenSearch and MozSearch plugins</h2>
<p>To install either an OpenSearch or a MozSearch plugin, you need to use the <code>window.external.AddSearchProvider()</code> DOM method.  The syntax for this method is:
</p>
<pre class="eval">window.external.AddSearchProvider(<i>engineURL</i>);
</pre>
<p>Where <i>engineURL</i> is the URL to the XML file for the search engine plugin.
</p>
<div class="note"><b>Note:</b> OpenSearch and MozSearch support is available only in Firefox 2 and later.</div>
<p>For details on MozSearch, see <a href="en/Creating_MozSearch_plugins">Creating MozSearch plugins</a>.
</p>
<h2 name="Installing_Sherlock_plugins">Installing Sherlock plugins</h2>
<p>To install a Sherlock plugin, you need to call <code>window.sidebar.addSearchEngine()</code>, the syntax for which is:
</p>
<pre class="eval">window.sidebar.addSearchEngine(<i>engineURL</i>, <i>iconURL</i>, <i>suggestedName</i>, <i>suggestedCategory</i>);
</pre>
<ul><li> The <code>engineURL</code> parameter is the URL to the Sherlock plugin (a ".src" file) to install.
</li><li> <code>iconURL</code> is the URL to an icon to associate with the plugin.
</li><li> The <code>suggestedName</code> parameter is only used when prompting the user for permission to install the plugin, so that a message such as "Do you want to install <i>suggestedName</i> from <i>engineURL</i>?" can be displayed.
</li><li> The <code>suggestedCategory</code> parameter is not used.  You should specify either an empty string (<code>""</code>) or <code>null</code>.
</li></ul>
<p>For details on Sherlock, visit http://developer.apple.com/macosx/sherlock/
</p>{{ wiki.languages( { "ja": "ja/Adding_search_engines_from_web_pages" } ) }}
Revert to this revision