|
JavaScript Bug:
Avoid Nested Tables
by Tom Dahm,
Chief Operations Officer,
NetMechanic, Inc.
JavaScript can be very useful for displaying different versions of a page based on the type of browser being used. If you do this, though, be careful about using JavaScript inside a nested table. Versions 2 and 3 of Netscape Navigator have a bug that prevents certain JavaScript statements from working properly when imbedded inside a nested table.
Consider the follow code:
<TABLE BORDER = 1>
<TR>
<TD>
<TABLE BORDER = 1>
<TR>
<TD>
<SCRIPT LANGUAGE="JavaScript">
document.write("hello world!");
</SCRIPT>
</TD>
</TR>
</TABLE>
</TD>
</TABLE>
|
|
|
Figure 1 - Table Containing JavaScript
When viewed with Netscape Navigator Version 4, or any Microsoft browser that supports JavaScript, this code will print a table containing the phrase "hello world." When viewed with Netscape Navigator Version 2 or 3, you will either see nothing or see the text outside of the table.
This problem only affects JavaScript's document.write() method. Other methods and statements are unaffected.
With the official release of Navigator 4.5, does this browser quirk still matter? Current data for NetMechanic shows that 17% of users are still using Netscape Navigator Version 3. So, yes, for the time being you still need to be careful.
|