Forum Moderators: open
What am I missing here?
Typically, I would say no. But, there are some subtle differences. In recent versions of IE (6 and later) there are really no major differences as compared to Firefox. But, that doesn't mean that code produced by various editors are not still using IE proprietary objects. Since IE6 obviously still supports the proprietary script, the result may be something that works in IE, but not in FF.
Let me guess -- the script uses
document.all?
The big differences, historically, have been in the object models offered by the browsers themselves.
..but since this wasn't really the question being asked, I'll cease my hair-splitting.
The biggest cause for threads entitled: "Why doesn't my script work in ..." on any browser scripting forum, have traditionally been the non W3C referencing system that IE initially used, and continues to support. It found its way into many MS tutorials and examples.
For instance, to reference an element with id, "test", you can do either of these:
document.all.test
test
Yes, element ids actually become part of the global scripting namespace. Quite convenient in a way.
At some point a while back these "Why .." threads dried up. The reason is that other browser producers got tired of all the sloppy coders making sites that didn't work with their browsers. Both Mozilla and Opera now secretly support both the above referencing methods - although you will get a warning in your Javascript console, if you care to look.
Try it:
<p id="test">Hello</p>
<script type="text/javascript">
alert(document.all.test.innerHTML)
alert(test.innerHTML)
</script> ..just as they found innerHTML useful too.
Conclusion: The problem may lie elsewhere.
<edit>
..and then again, it might not. Input boxes may be a different matter.
</edit>
<tr>
<td width="33%">Side Angle A <input name="AngleA" onkeypress="return numbersonly()"
size="6" value="45" tabindex="1"> degrees</td>
<td width="33%">Side Angle B <input name="AngleB" onkeypress="return numbersonly()"
size="6" tabindex="2" value="45"> degrees</td>
<td width="34%">Valley Angle C <input type="text" name="AngleC" size="6" tabindex="3">
degrees</td>
</tr>
<tr>
<td width="100%" colspan="3" align="center"><input type="button" onclick="calc(form)"
value="Calculate" name="B1" tabindex="4"></td>
</tr>
Mozilla is triggering a keypress event for these useful keys too
[backspace],[del],[<],[>]
That is
8,46,37,39
function numbersonly(e)
{
var kc = e.keyCode;
return (kc>=48 && kc<=57) ¦¦ !!{8:1,46:1,37:1,39:1}[kc];
}
Tip: For getting normalised key values across browsers for characters use:
var kc = e.which¦¦e.keyCode;
[edited by: DrDoc at 12:26 am (utc) on Feb. 5, 2006]