[thelist] Anti-Netscape tips

David Shadovitz david_shadovitz at xontech.com
Wed Nov 22 17:34:39 CST 2000


I owe, so here are two things I learned today.  Apologies if these are
well-known issues.
-David

<tip type="Form elements with no value attribute" author="David
Shadovitz">

Consider these two hidden form elements:
   <input type="hidden" name="dummy1">
   <input type="hidden" name="dummy2" value="">

In IE 5.0, the action page sees the value of each of these elements as
"".
In Netscape 4.5, the action page sees the value of the 1st one as " "
and the 2nd as "".

Netscape's differentiation between these two was a surprise to me.
If you don't want to use the value attribute, make sure your action page
trims the form elements.

</tip>

<tip type="Netscape and the Option() constructor" author="David
Shadovitz">

As of JS 1.1, options may be created dynamically, like so:
  new Option(text, value[, defaultSelected, selected])

The last two arguments are optional and specify whether the new option
is selected.

I found that Netscape 4.5 & 4.7 disregard the values of those two
arguments and always select a new option created this way!  IE 5.0 obeys
the rules.  You can get around the problem by omitting these arguments
and then setting the new option's properties.

Here's a page demonstrating the flaw, if my HTML gets through:

<html>
<head></head>
<body>
<form>
<select name="guys" multiple size="10">
  <option value="Tom">Tom</option>
  <option value="Dick">Dick</option>
  <option value="Harry">Harry</option>
</select>&nbsp;
<input type="button" value="Add a guy" onclick="var g = new
Option('Alfred', 'Alfred', false,
false);this.form.guys.options[this.form.guys.length] = g">
</form>
</body>
</html>

</tip>





More information about the thelist mailing list