Can you make this javascript work in Mozilla/firefox and IE?

This code is a part of a report on my site that expands hidden text. It doesn’t work in firefox, but works perfect in Internet Explorer. Can anyone alter this code so it works in both correctly?

Here is a link to the functioning report

<tr>
<td bgcolor="$altbg2" class=“tablerow”>
<DIV ID=“el$post[pid]Parent” CLASS=parent>
<A HREF="#" onClick=“expandIt(‘el$post[pid]’); return false”>+
<FONT COLOR="#003333"></FONT>

$post[title]</A>
</DIV>
</td>
<td bgcolor="$altbg1" class=“tablerow”>$post[author]</td>

<td bgcolor="$altbg1" class=“tablerow”>$post[average_rating]</td>
<td bgcolor="$altbg2" class=“tablerow”>$post[votes]</td>

$post[yourrating]

$post[ratingvariable]

</tr>
<tr>
<td bgcolor="$altbg1" class=“tablerow” colspan=“6”>
<DIV ID=“el$post[pid]Child” CLASS=child><FONT COLOR="#003333">

$post[message] <a href=“viewthread.php?tid=$post[tid]#pid$post[pid]”>
(Go to the original thread)</a>
<br><br>
<a href=“post.php?action=reply&fid=$post[fid]&tid=$post[tid]”><img
src="$imgdir/reply.gif" border=“0” alt=“Reply to Post” align=“left”/>
</a>

<a href=“post.php?action=reply&fid=$post[fid]&tid=$post[tid]&repquote=$post[pid]”>
<img src="$imgdir/quote.gif" border=“0” alt=“Quote Post”
align=“right”/>
</a>

<a href=“post.php?action=edit&fid=$post[fid]&tid=$post[tid]&pid=$post[pid]”>
<img src="$imgdir/edit.gif" border=“0” alt=“Edit Post” align=“right” />
</a>

</FONT>
</DIV>
</td>
</tr>

This table row is displayed dynamically in the report. Any help is appreciated. Thanks.

Matt

You haven’t actually given us any Javascript there. But looking at the source from your website, it appears that the code is written for Internet Explorer and Netscape 4, only. The code to detect which browser is being used relies on older, deprecated DOM features not supported by Mozilla/Firefox (not yet, anyway):


NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4))?true:false;

  • both NS4 and IE4 will be false, causing problems later in the script because of some careless assumptions, e.g.

   if (NS4) {
       // do something
   }
   else {
       // do something else
       }
   }

The second part, which is supposed to be for IE only, will be executed under Firefox too, but of course it won’t work.

Basically, everywhere there are currently two versions of a section of code, one for IE and one for Netscape 4, you need a third version for browsers that were designed after the Stone Age.

(Wouldn’t you be better off posting this to a Javascript forum?)