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

**URL:** https://boards.straightdope.com/t/can-you-make-this-javascript-work-in-mozilla-firefox-and-ie/257652
**Category:** Factual Questions
**Created:** [July 30, 2004, 9:52pm UTC](https://boards.straightdope.com/t/can-you-make-this-javascript-work-in-mozilla-firefox-and-ie/257652 "2004-07-30T21:52:21Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ready29003](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@ready29003](https://boards.straightdope.com/u/ready29003)
#### Post date: [July 30, 2004, 9:52pm UTC](https://boards.straightdope.com/t/can-you-make-this-javascript-work-in-mozilla-firefox-and-ie/257652/1 "2004-07-30T21:52:21Z")

</div>

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](http://www.thesearchforwisdom.com/community/boards/topicsolutions.php?action=result&desc=desc&fid=134&tid=169&author=&solution=1&votes=&order=average_rating)

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

---

<div class="post-metadata">

### Author: ![Ximenean](https://avatars.discourse-cdn.com/v4/letter/x/aca169/32.png) [@Ximenean](https://boards.straightdope.com/u/Ximenean)
#### Post date: [July 31, 2004, 12:36am UTC](https://boards.straightdope.com/t/can-you-make-this-javascript-work-in-mozilla-firefox-and-ie/257652/2 "2004-07-31T00:36:17Z")

</div>

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

```auto

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.

```auto

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