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

<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>

<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>



<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>
<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 href=“post.php?action=reply&fid=$post[fid]&tid=$post[tid]&repquote=$post[pid]”>
<img src="$imgdir/quote.gif" border=“0” alt=“Quote Post”

<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” />


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


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;

  • 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?)