December 30th, 2008. This post was published long time ago on the Italian version of my blog then moved here after the English blog has been opened. Please note that the following post can contain outdated information and (probably) multiple typos.
Firefox 2.0 is out… uhm? what are you saying? what a great news?… oh yeah, but this isn't the main topic of this post.
As someone of you probably remember, on June I made a few tests with Firefox 2.0 Bon Echo 3 focused on how the new Firefox handles feeds. Firefox 2 gives you full control over Web feeds, showing you a preview and letting you choose how you want to subscribe.
At the end of the tests I wrote an article showing how is possible to add a new content handler, aka web aggregator, in Firefox 2.0… it was digged too! (Note. The article is no longer available). Since Firefox 2.0 was not yet released at the time the article was written, I didn't know that there was an easier way to add an content handler without tweaking by hand Firefox registry.
Adding a new feed handler to Firefox 2.0 with registerContentHandler()
It accepts 3 required params:
- the content mime type.
For a feed must be
- the content handler URI.
%scan be used as a placeholder for the resource URI.
- the content handler Title
Once again, let's use Rmail as example.
Rmail add-new-subscription URI is (always the same)
http://www.r-mail.org/bm.aspx?rss=%s while content handler title is Rmail.
navigator.registerContentHandler('application/vnd.mozilla.maybe.feed', 'http://www.r-mail.org/bm.aspx?rss=%s', 'Rmail');
Look & feel
Click here and add Rmail
… you can put it into a form button…
Look & feel
<p> <input type="button" name="add" value="Click here and add Rmail" onclick="window.navigator.registerContentHandler('application/vnd.mozilla.maybe.feed', 'http://www.r-mail.org/bm.aspx?rss=%s','Rmail');" /> </p>
More power to registerContentHandler()
This tutorial might be closed here, but the real reason why I wrote this post is to show how is possible to add more power to
The idea comes from this post where Randy shows a button to add Rmail as a new content handler. In a comment pat asks which is the best technique between Randy's magic button (see example 2 and example 3) and my tutorial (Note. The tutorial is no longer available).
This is Randy's answer.
Pat, Simone's technique is actually superior as it also includes the email address. I'm working on making that possible too! Randy
Don't worry Randy, I will give you an help! :D
The only difference between my code and Randy's code is that I used the following Rmail subscription string (please note the mailto param)
Thus, what we should do is find a way to allow user to type its own email address and append it to the content handler URI.
While I was writing the code, I decided to do a little more. Why not creating a script that allows developers to add custom arguments to a content handler URI instead of a single one? Rmail just needs a
mailto param but other readers may need
This is what I wrote!
The following script allows you to register a new content handler in Firefox 2.0 just calling a simple function.
In addition, you can create as many form field as you wish calling them
name="args". For each field, the script will collect its value and if the field isn't empty, will appends the value to the content handler URI.
Let's see an example. Again, I will use Rmail and I will show you how it's easy to append your personal email to the URI.
First you must include the script.
Don't forget to customize
Then add an input text field for each argument you wish to append to the URI. You can also use hidden inputs to pass hidden values. Don't forget to call them
args or the script will not work.
Now call the
Enjoy the confirmation dialog! :D