Re: JavaScript error with onChange event handler -- FireFox 1.5




David McNerney wrote:
Would anyone be able to tell me why I get an error in FireFox 1.5.0.1
for MacOSX when I type some text and hit Enter in the following form:

<html>
<body>
<form action="http://example.com"; onSubmit="return false;">
<input type="text" name="samplenum" value=""
onChange="alert('onChange fired');">
<input type="submit" name="cmd_submit" value="Submit"
onClick="return false">
</form>
</body>
</html>

Needless to say, this is a pruned down toy example. It seems like there
must be a bug, but I'd like to make sure that I'm not doing something
wrong. I don't get the error if I remove the onChange event handler.
The error reads:

Error: [Exception... "'Permission denied to set property
XULElement.selectedIndex' when calling method:
[nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::
file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html ::
onchange :: line 1" data: no]
Source File:
file:///Users/dave/sy_dir/u01/app/lims/httpd/htdocs/ajax.html
Line: 1

That looks like the old autocomplete bug, but it was fixed in Firefox
1.5. Are you sure that your version is 1.5 and not say 1.0.7? If indeed
then somehow it was preserved in the MacOS build. Under Windows (98 and
XP) it was fixed for sure - I don't know why other respondent says it
was not. You code runs w/o exceptions on test machines.

The fix is to use autocomplete="off"

<input type="text" name="samplenum" value=""
autocomplete="off"
onChange="alert('onChange fired');">

Of course it is not an option if you *need* to have autocomplete on.
Also this bug leads to an exception, not to an error: it means that
script execution is not aborted. But numerous exceptions may lead to an
execution slow-down (plus JavaScript console gets "pollued")

.



Relevant Pages

  • Re: Structured exception information
    ... subprograms should raise exceptions because of precondition ... A precondition violation is not an exceptional state, it is a bug. ...
    (comp.lang.ada)
  • Re: Exception handling philosophy
    ... Richard Grossman wrote: ... The reports and dialogs displayed could be very helpful and look very professional. ... > 2 There are exceptions that are explicitly handled, such as during opening and saving files, and don't need any additonal handling since they represent a local issue and not a bug. ...
    (borland.public.delphi.non-technical)
  • Re: Kann Java nicht mit Byte-Zahlen rechnen?
    ... - * Exceptions werfen könnten. ... gedeckten Sicherheit geschrieben sind, daß ... Bug gefixt wird ist das ja nie rückwärtskompatibel, ... Und wie Integer-Arithmetik ...
    (de.comp.lang.java)
  • Re: Writing bulletproof code
    ... If your program has a bug that you ... client and library code, when we let the client programmer goof ... Arthur Arthur gcc warning at compile time, ... Exceptions allow graceful management of errors. ...
    (comp.programming)