s l a m
WEB PUBLISHING'S FRONTIER



Subscribe to "s l a m" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

© copyright 2004
by Marc Barrot.

Permalink
Saturday, April 20, 2002

radioScan Widget Fixed

radioScan is a javascript widget I created so that readers could browse through s l a m 's post titles in a side window, while displaying the whole post in the main browser window whenever they click on a title. Try it from the left sidebar.

radioScan adds an alternate, more topic oriented, way of accessing s l a m 's content, in addition to the chronological weblog method (not that there's much content on s l a m yet, but this is going to change eventually :-)

I've been struggling on and off for 2 weeks, trying to find out why the javascript code was working fine with later versions of Internet Explorer, but failing miserably with Gecko based browsers such as Mozilla and Netscape.

While re-reading the messages I had received after asking for help (thanks everyone btw, this is a great community), and after reviewing some other, unrelated, code, I finally saw the light: as usual, it was a lot simpler (and dumber) than I thought :-)

So here are the gory details.

What radioScan does is define a 'table of contents' javascript object class, with 2 methods, reset and write. To do this, I had first written the table object contructor function, Toc(), then both class methods, using the following syntax:

function Toc.prototype.reset() { some code ... }
function Toc.prototype.write() { some other code ... }

Wrong move, didn't please Gecko.

What works is to define the reset and write functions independently, before the Toc object constructor function, with something like:

function Reset_Toc() { some code ... }
function Write_Toc() { some other code ... }

Then, after the Toc constructor function, add 2 lines like this:

Toc.prototype.reset = Reset_Toc;
Toc.prototype.write = Write_Toc;

That's all there is to it. When I create a Toc class object in the onload attribute of the widget's frameset definition, Gecko doesn't drop dead any more:

onload="toc = Toc(); toc.reset();"

Mozilla 1.0rc1 actually runs the code faster on my Powerbook/MacOS X system than Internet Explorer. So far, I've tested radioScan with all later versions of IE on Windows 98, NT4, MacOS 9, and MacOS X, with Mozilla 1.0rc1 on MacOS X and Linux RedHat 7.2, and with Netscape 6 on MacOS 9 and MacOS X.

To download the updated package, refer to the storyList and radioScan howto.

12:47:26 AM  Permalink    Google It!  


April 2002
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
Mar   May

last updated: 3/20/04; 5:22:13 PM.