How to add search engines in Firefox - e.g. LEO dictionary - troubleshooting
Adding search engines for the Firefox search engine toolbar is easy. We will analyze this by looking
at the LEO english-german-english dictionary.
If you ended up on this page, because the entry for LEO doesn't show up, click here:
TROUBLESHOOTING on Linux
There is a little javascript involved:
function addEngine(name,ext,cat)
{
if ((typeof window.sidebar == "object") && (typeof
window.sidebar.addSearchEngine == "function"))
{
window.sidebar.addSearchEngine(
"http://www.leo.org/dict/plugins/"+name+".src",
"http://www.leo.org/dict/plugins/"+name+"."+ext,
name,cat);
alert('Download completed');
}
else
{
errorMsg(name,ext,cat);
}
}
The function addEngine invokes the Firefox-builtin window.sidebar.addSearchEngine function to actually add
the .src file and the icon. This function is called with the javascript-link:
<a href="javascript:addEngine('leo','png','Language dictionary')">LEO dict</a>
The Firefox-javascript-function window.sidebar.addSearchEngine then downloads the leo.src file. It's content
is shown here:
<SEARCH
name="Leo Eng-Ger"
description="Dict.Leo.org - Translate English to German or German to English"
action="http://dict.leo.org/"
showif=""
queryCharset="iso-8859-15"
method="GET"
>
<input name="lp" value="ende" label="English-German" grouptitle="Select languagpair:">
<input name="lp" value="frde" label="French-German">
<input name="search" user>
<input name="searchLoc" value="0">
<input name="relink" value="on">
<input name="spellToler" value="standard">
<input name="cmpType" value="relaxed">
</search>
This file is placed in /usr/firefox/searchplugins/ aswell as the leo.png icon.
This is where the following problem can can occur.
TROUBLESHOOTING on Linux:
If you installed Firefox as root and now run Firefox as normal user, Firefox might not be able
to write into the /usr/firefox/searchplugins/ directory. Either change the permissions for the
directory "searchplugins" (attention: this enables write access to other users and might cause
a security problem) or copy the LEO files into /usr/firefox/searchplugins/ manually.
By analyzing the javascript, we see that there are 2 files downloaded and installed:
<a href="javascript:addEngine('leo','png','Language dictionary')">LEO dict</a>
function addEngine(name,ext,cat)
[...]
"http://www.leo.org/dict/plugins/"+name+".src",
"http://www.leo.org/dict/plugins/"+name+"."+ext,
Hence, the full URL's of the files are:
http://www.leo.org/dict/plugins/leo.src
http://www.leo.org/dict/plugins/leo.png
Download these files and copy them to /usr/firefox/searchplugins/ as root user. Those files
and the "searchplugins" directory will only be writable by the root user, but readable by
any other user.
Further details:
If you compare the leo.src file with the actual URL when you search for a word, the whole
.src file is self-explanatory:
http://dict.leo.org/?lp=ende&lp=frde&search=test&searchLoc=0&relink=on&spellToler=standard&cmpType=relaxed
Each "input"-field in the .src-file is either appended (GET-method) to the action URL in the SEARCH-tag or
POSTed to the URL, depending on the "method". This is like regular HTML-forms work.
In order to tell Firefox, which input-field is the actual input-field for the search-query, one just needs
to added the "user" keyword to the search-field:
<input name="search" user>
Conclusion:
Due the well designed interface of Firefox one is not limited to add any search-engine, but also
any other webpage which is requested via GET or POST and requires one input field.
Last-Modified: Sat, 04 Feb 2006 16:03:15 GMT