JavaScript error with onChange event handler -- FireFox 1.5

D

David McNerney

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
 
Z

Zif

David McNerney said on 05/04/2006 11:38 AM AEST:
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

You'll be pleased to know that the same thing happens in Firefox on
Windows. It's related to the 'onclick' attribute you've put on the
submit button - get rid of that and the error goes away.

It may still be worth logging a bug since it doesn't happen if you click
the submit button or don't fire the onchange simultaneously (e.g. cause
the onchange to fire first by tabbing or blurring the control, then do a
submit).

Other than the error message, does your form scripting malfunction as a
result?
 
V

VK

David said:
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")
 
Z

Zif

VK said on 05/04/2006 6:25 PM AEST:
[...]
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.

Because, when tested, it behaved exactly the same for Firefox 1.5.0.1 on
Windows XP as the OP described for Mac OS X. Re-testing today shows it
hasn't changed.

I don't presume to guess why.

You code runs w/o exceptions on test machines.

That was not the result here.

The fix is to use autocomplete="off"

Yes, that 'fixes' it.

[...]
 
D

David McNerney

Thank everyone for the information! My script didn't malfunction, but
the error caused me some confusion in debugging an unrelated browser
hang. Definitely FF 1.5 BTW.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top