<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Simone Carletti&#039;s Blog &#187; firefox</title>
	<atom:link href="http://www.simonecarletti.com/blog/tags/firefox/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simonecarletti.com/blog</link>
	<description>Simone Carletti&#039;s personal ramblings on programming, syndication, search engines &#38; marketing.</description>
	<lastBuildDate>Thu, 12 Jan 2012 09:16:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to add a new feed handler in Firefox 2.0</title>
		<link>http://www.simonecarletti.com/blog/2006/11/how-to-add-a-new-feed-handler-in-firefox-20/</link>
		<comments>http://www.simonecarletti.com/blog/2006/11/how-to-add-a-new-feed-handler-in-firefox-20/#comments</comments>
		<pubDate>Sat, 04 Nov 2006 15:45:40 +0000</pubDate>
		<dc:creator>Simone Carletti</dc:creator>
				<category><![CDATA[Softwares]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[registercontenthandler]]></category>

		<guid isPermaLink="false">http://www.simonecarletti.com/blog/2006/11/how-to-add-a-new-feed-handler-in-firefox-20/</guid>
		<description><![CDATA[How to add a new feed handler to Firefox 2.0 without tweaking the registry.
]]></description>
			<content:encoded><![CDATA[<div class="flash-message warning">
<p><strong>December 30th, 2008</strong>. 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.</p>
</div>
<p>Firefox 2.0 is out&#8230; uhm? what are you saying? what a great news?&#8230; oh yeah, but this isn&#8217;t the main topic of this post.</p>
<p>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.</p>
<p>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&#8230; <a href="http://digg.com/software/How_to_add_Rmail_as_a_choice_in_Firefox_2_0">it was digged too</a>! <em>(Note. The article is no longer available)</em>.<br />
Since Firefox 2.0 was not yet released at the time the article was written, I didn&#8217;t know that there was an easier way to add an content handler without tweaking by hand Firefox registry.</p>
<p>Using <code>registerContentHandler()</code> javascript function is possible to add with just one click a new feed handler&#8230; how? Let me show you.</p>
<p><span id="more-12"></span></p>
<h2>Adding a new feed handler to Firefox 2.0 with registerContentHandler()</h2>
<p><a href="https://developer.mozilla.org/En/DOM:window.navigator.registerContentHandler">registerContentHandler()</a> is a JavaScript function that allows you to register a new content handler in Firefox 2.0.<br />
It accepts 3 required params:</p>
<dl>
<dt><var>mimeType</var></dt>
<dd>the content mime type.<br />
For a feed must be <code>application/vnd.mozilla.maybe.feed</code>. </dd>
<dt><var>uri</var></dt>
<dd>the content handler URI.<br />
<code>%s</code> can be used as a placeholder for the resource URI. </dd>
<dt><var>title</var></dt>
<dd>the content handler Title</dd>
</dl>
<p>Once again, let&#8217;s use Rmail as example.<br />
Rmail add-new-subscription URI is (always the same) <code>http://www.r-mail.org/bm.aspx?rss=%s</code> while content handler title is Rmail.<br />
Thus, the final JavaScript should looks like the following.</p>
<div class="codecolorer-container text default brush: plain" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">navigator.registerContentHandler('application/vnd.mozilla.maybe.feed',<br />
'http://www.r-mail.org/bm.aspx?rss=%s',<br />
'Rmail');</div></td></tr></tbody></table></div>
<p>You can put/call this JavaScript function where everywhere in a HTML page, for example as a link (<a href="http://blog.netvibes.com/?2006/10/25/83-firefox-2-and-netvibes">as Netvibes did</a>)&#8230;</p>
<h3>Example 1.</h3>
<p><strong>Look &amp; feel</strong></p>
<p><!-- example 1 l&#038;f --></p>
<p><a href="javascript:window.navigator.registerContentHandler('application/vnd.mozilla.maybe.feed','http://www.r-mail.org/bm.aspx?rss=%s','Rmail');">Click here</a> and add Rmail</p>
<p><!-- /example 1 l&#038;f --></p>
<p><strong>Code</strong></p>
<p><!-- example 1 code --></p>
<div class="codecolorer-container text default brush: html" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;p&gt;<br />
&lt;a href=&quot;javascript:window.navigator.registerContentHandler('application/vnd.mozilla.maybe.feed',<br />
'http://www.r-mail.org/bm.aspx?rss=%s','Rmail');&quot;&gt;Click here&lt;/a&gt;<br />
and add Rmail<br />
&lt;/p&gt;</div></td></tr></tbody></table></div>
<p><!-- /example 1 code --></p>
<p>&#8230; you can put it into a form button&#8230;</p>
<h3>Example 2.</h3>
<p><strong>Look &amp; feel</strong></p>
<p><!-- example 2 l&#038;f --></p>
<input onclick="window.navigator.registerContentHandler('application/vnd.mozilla.maybe.feed',&lt;br /&gt; 'http://www.r-mail.org/bm.aspx?rss=%s','Rmail');" name="add" type="button" value="Click here and add Rmail" />
<p><!-- example 2 l&#038;f --></p>
<p><strong>Code</strong></p>
<p><!-- example 2 code --></p>
<div class="codecolorer-container text default brush: html" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;p&gt;<br />
&lt;input type=&quot;button&quot; name=&quot;add&quot; value=&quot;Click here and add Rmail&quot;<br />
onclick=&quot;window.navigator.registerContentHandler('application/vnd.mozilla.maybe.feed',<br />
'http://www.r-mail.org/bm.aspx?rss=%s','Rmail');&quot; /&gt;<br />
<br />
&lt;/p&gt;</div></td></tr></tbody></table></div>
<p><!-- /example 2 code --></p>
<p>or include it into a JavaScript function and call it anywhere in the page.</p>
<h3>Example 3.</h3>
<p><strong>Code</strong></p>
<p><!-- example 3 code --></p>
<div class="codecolorer-container text default brush: html" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;script type=&quot;text/javascript&quot;&gt;<br />
function subWith() {<br />
navigator.registerContentHandler('application/vnd.mozilla.maybe.feed', 'http://www.r-mail.org/bm.aspx?rss=%s', 'Rmail');<br />
}<br />
<br />
&lt;/script&gt;<br />
&lt;input type=&quot;button&quot; name=&quot;add&quot; value=&quot;Click here and add Rmail&quot;<br />
onclick=&quot;function subWith();&quot; /&gt;</div></td></tr></tbody></table></div>
<p><!-- /example 3 code --></p>
<h2>More power to registerContentHandler()</h2>
<p>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 <code>registerContentHandler()</code> with a few JavaScript lines.</p>
<p>The idea comes from this post where <a href="http://www.therssweblog.com/">Randy</a> shows a button to add Rmail as a new content handler.<br />
In a comment <cite>pat</cite> asks which is the best technique between Randy&#8217;s magic button (see example 2 and example 3) and my tutorial <em>(Note. The tutorial is no longer available)</em>.</p>
<p>This is Randy&#8217;s answer.</p>
<blockquote><p>Pat,<br />
Simone&#8217;s technique is actually superior as it also includes the email address. I&#8217;m working on making that possible too!<br />
Randy</p></blockquote>
<p>Don&#8217;t worry Randy, I will give you an help! :D</p>
<p>The only difference between my code and Randy&#8217;s code is that I used the following Rmail subscription string (please note the mailto param)</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://www.r-mail.org/bm.aspx?rss=%s&lt;strong&gt;&amp;mailto=YOUR_EMAIL&lt;/strong&gt;</div></td></tr></tbody></table></div>
<p>instead of</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://www.r-mail.org/bm.aspx?rss=%s</div></td></tr></tbody></table></div>
<p>Thus, what we should do is <strong>find a way to allow user to type its own email address and append it to the content handler URI</strong>.</p>
<p>My first idea was to <strong>create a new input text field</strong>. It&#8217;s better than using other techniques such as JavaScript input boxes since the field can be easily filled with a server side programming language in a more complex site, can be validated and you can re-use in thousand ways.<br />
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 <code>mailto</code> param but other readers may need <code>mail</code> and <code>user</code>&#8230;</p>
<p>This is what I wrote!</p>
<p>The following script allows you to register a new content handler in Firefox 2.0 just calling a simple function.<br />
In addition, you can create as many form field as you wish calling them <code>name="args"</code>. For each field, the script will collect its value and if the field isn&#8217;t empty, will appends the value to the content handler URI.</p>
<p>Let&#8217;s see an example. Again, I will use Rmail and I will show you how it&#8217;s easy to append your personal email to the URI.</p>
<h3>Example 4.</h3>
<div class="codecolorer-container text default brush: html" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;!-- include the script --&gt;<br />
&lt;script type=&quot;text/javascript&quot; src=&quot;firefox2-registerFeedHandler.js&quot;&gt;&lt;/script&gt;<br />
<br />
&lt;!-- add as many field as you wish.<br />
Each field called 'args' will be appended to content handler URI.<br />
The argument name will be its unique form Id, the value the field value.<br />
--&gt;<br />
&lt;input type=&quot;text&quot; name=&quot;args&quot; id=&quot;email&quot; value=&quot;&quot; /&gt;&lt;br /&gt;<br />
<br />
&lt;!-- call the function, use subWith(true) instead of subWith()<br />
to collect form fields.<br />
--&gt;<br />
&lt;input type=&quot;button&quot; name=&quot;subWith&quot; onclick=&quot;subWith(true);&quot; value=&quot;Make Rmail your Firefox RSS handler&quot; /&gt;</div></td></tr></tbody></table></div>
<p>First you must include the script.<br />
Don&#8217;t forget to customize <code>chUri</code> and <code>chTitle</code> variables, as written at the top of the javaScript file.</p>
<p>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.<strong> Don&#8217;t forget to call them <code>args</code> or the script will not work.</strong></p>
<p>Now call the <code>subWith()</code> function. You can use a link, a button or a common JavaScript event.</p>
<p>Enjoy the confirmation dialog! :D</p>
<p><img class="centered" src="http://www.simonecarletti.com/blog/public/2006/11/firefox_new_feed_handler/dialog.gif" alt="Add new handler confirmation dialog" /></p>
<p>Related posts<ol>
<li><a href='http://www.simonecarletti.com/blog/2006/06/feedburner-stats-2-feed/' rel='bookmark' title='FeedBurner Stats 2 Feed'>FeedBurner Stats 2 Feed</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.simonecarletti.com/blog/2006/11/how-to-add-a-new-feed-handler-in-firefox-20/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

