Permission Denied to Set Property XULElement.selectedIndex

Sorry for the late post this week. I have been working hard on the YUI storage project and the new release for and did not finish my post in time. Todays article covers an issue you may experience when using the native DOMElement focus and select functions in FireFox.

If you have FireBug running, the exception is:

"Permission denied to set property XULElement.selectedIndex"

followed by a pointer to the offending line.

The issue is that when you use "element.focus()" and/or "", FireFox attempts to manipulate the built in autocomplete feature. However, it does not always do that correctly. I am not exactly sure what is going on in the FireFox code, but it seems to only happen on fields where the built in browser autocomplete was previously triggered. As long as you do not care about the built in FireFox autocomplete, the fix is very easy, simply add the attribute autocomplete and give it a value of false.

Example 1: In HTML

<input autocomplete="off" type="text" value"some text"/>

Example 2: In JavaScript

element.setAttribute(autocomplete, off);

Example 1 will cause any HTML validator to fail, so you may want to set this attribute via JavaScript (Example 2). Example 2 will fix the issue in FireFox and simply be ignored by other browsers.