Mozilla autocomplete bug
Wednesday, 12 October 2005
I recently came across an annoying little bug which seems to affect all Mozilla based browsers, including the current version (1.07) of Firefox. It seems to happen when you have a form text input field and you’re using Javascript to validate whether the user has entered anything into that input field. So, for instance if you had a text input field like this:
<input type="text" name="name" value="" />
And then you had some Javascript validation on the field like this:
if (document.forms[0].elements['name'].value == '') {
document.forms[0].elements['name'].focus();
alert("You did not specify the name.");
return false;
}
You would get this exception error in your Javascript console:
“Permission denied to get property XULElement.selectedIndex when calling method: [nsIAutoCompletePopup::selectedIndex]”
It seems to occur whenever you try to force focus (via Javascript) on a text input field with the “autocomplete” attribute switched on, which is the default. Mozilla have acknowledged this as a low priority bug and presumably there’s a fix sometime in the future. The interim solution is to explicitly disable “autocomplete” when defining the text input field:
<input type="text" name="name" value="" autocomplete="off" />
|