spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / scripts / sidebar To page 1To page 2To page 3To page 4To page 5current page
[previous]

The Multi-Feed RSS Sidebar Tab

Senior Web Analytics Engineer
Professional Technical Resources
US-OR-Beaverton

Justtechjobs.com Post A Job | Post A Resume
Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Wrap Up

Using various techniques we've learned in other areas of WebRef and perhaps throwing in a couple new ones, we've created a light and quick multi-feed sidebar tab suitable for use in Netscape 6/Mozilla now, or possibly other browsers and platforms in the future. Additionally, we've left our page design open enough that we could conceivably craft a completely different HTML look without adjusting our code; and (depending on how you setup your &getFeeds function) we can add new feeds to our tab easily without having to change the HTML display. Our finished, optimized HTML page (the one with unnecessary spaces removed, but otherwise identical to the page discussed here) validates as XHTML transitional (and if not for that darn target attribute would validate as XHTML strict) and rings in at just over 5k including a full page's worth of data.

Once you finish your tab, don't forget to submit it to Netscape's Sidebar Tab directory, which is available from the "Today's Tips" tab and the tab customization screen of both Netscape and Mozilla (you can find the submit form in Netscape's Sidebar Tab documentation). We make no promises as to whether your tab will get into the directory or not, or even whether the directory is still being updated (we haven't seen a whole lot of new entries there in quite some time). But it only takes a moment, so it's worth a shot.

Finally, promote your tab on your own site; so your fans can add it directly to their own Netscape 6/Mozilla sidebars. Netscape suggests code something like the following to do this:

<SCRIPT LANGUAGE="JavaScript"> 
function addTab() { 
  if ((typeof window.sidebar == "object") && 
      (typeof window.sidebar.addPanel == "function")) 
  { 
      window.sidebar.addPanel("internet.com Multi-Feed",
           "http://headlines.internet.com/cgi-bin/feedtab.cgi?feed=webref/news.rss",""); 
  } else { 
      alert('Sorry, you can only add the tab if you\'re running Netscape 6 or Mozilla.');
  } 
} 
</SCRIPT>

   ...

<a href="javascript:addTab()">Add this site to your sidebar</a>

Netscape also offers a special button graphic especially for the purpose. The key addPanel method takes three arguments: the feed name (displayed on the top of the tab), the feed URL, and a URL that allows for the tab to be customized (optional). In the above example, note that we're using feedtab's ability to request a specific feed, and serving up the WebReference listing directly. You can still access the other internet.com feeds via the "more feeds" link at the bottom of the initial feed display.

Using a JavaScript URL isn't the best solution since it'll crash (or try to send you to a site called "javascript:") for users with JavaScript turned off. Instead, consider something like this:

<a href="sorry.html" onclick="addTab(); return false">Add this site to your sidebar</a>

which allows non-JavaScript users to be gracefully redirected to a "sorry.html" page where you can more fully explain the problem.

Update: 05/20/2002: A bug in Netscape 6/Mozilla (see Bugzilla #97016) will prevent the browser from adding a new tab to the user's sidebar properly on the first try if the user has not yet opened their sidebar in the current browser session. Attempts to add a new entry to an already open sidebar via the above code seem to be fine; as do all second and subsequent attempts to add a tab (whether the sidebar is already open or not). Since this bug is currently marked as "future" in the Bugzilla database, developers should not expect it to be corrected in the browser soon.

We therefore recommend this improved and friendlier version of the above addTab() routine, which alerts the user of a problem in the event one is found and invites them to try again:

<SCRIPT LANGUAGE="JavaScript">
function addTab(tabName,tabURL,tabCURL) { 
  if ((window.sidebar) && (window.sidebar.addPanel)) {
      try {
         window.sidebar.addPanel(tabName,tabURL,tabCURL); 
      }
      catch (e) {
         alert('An error occurred when trying to add our tab to your '+
               'Sidebar. This is most likely the result of a known bug '+
               '(see Bugzilla #97016) in some Netscape6/Mozilla versions. '+
               'You should be able to click the add tab link again now '+
               'and it should work properly.\n\n'+
               'If you continue to have problems, try opening your sidebar '+
               'first, and then click the add tab link.');
      }
  } else { 
      alert('Sorry, you can only add the '+tabName+' tab if you are '+
            'running Netscape 6 or Mozilla.');
  } 
}
</SCRIPT>

   ...

<a href="sorry.html" onclick="addTab('internet.com Multi-Feed','http://headlines.internet.com/cgi-bin/feedtab.cgi?feed=webref/news.rss','')">Add this site to your sidebar</a>

Of course, if you use this routine you must be very careful that the arguments you pass into the function are correct; otherwise you run the risk of triggering the error message when the problem is really within your passed parameters. You may also wish to extend the above try..catch block to look specifically for the error returned as a result of the bug and handle all other errors differently.

# # #

About the Author

Dan Ragle is the Assistant Editor for WebReference.com, the Managing Editor of Internet Product Watch and "plays off the bench" for a number of other internet.com sites, including Flash Kit, Streaming Media World, and JavaScript.com. When not working on Web sites, Dan enjoys walking and music sequencing.


home / scripts / sidebar To page 1To page 2To page 3To page 4To page 5current page
[previous]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Working with the DOM Stylesheets Collection · Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Combine BottomCount() with Other MDX Functions to Add Sophistication · Creating a Daemon with Python · The Coming Voice-over-WiMAX Revolution

Created: May 17, 2002
Revised: May 20, 2002

URL: http://webreference.com/scripts/sidebar/6.html