Setting accesskey attribute using setAttribute() is case-sensitive

In Explorer, if you need to set the accesskey attribute using setAttribute(), the attribute name passed in must be "accessKey" and NOT "accesskey".

Test page Workaround is not included
Reported by: Toh Zhiqiang.

Explorer 5-6 Windows, Explorer 7, Explorer Mac | Reported on 29 July 2005.

This site is no longer maintained. I’m sorry, but it’s just too much work for too little return. You can continue to browse old bug reports, though.




Search reports by browser:

Atom RSS

Comments

(Add your own)

1 Posted by molily on 6 August 2005 | Permalink

I think this is a rather general setAttribute() bug, not limited to accesskey/accessKey.

If there is a special mixed case attribute name in DOM HTML ( http://www.w3.org/TR/DOM-Level-2-HTML/html.html ), you have to use this spelling in the first parameter for setAttribute().

Affected attributes (with their DOM HTML spelling):
className, httpEquiv, aLink, bgColor, vLink, acceptCharset, tabIndex, accessKey, readOnly, useMap, htmlFor, dateTime, isMap, codeBase, codeType, noHref, cellPadding, cellSpacing, chOff, vAlign, colSpan, noWrap, rowSpan, frameBorder, longDesc, marginHeight, marginWidth, noResize

I.e. document.body.setAttribute("bgcolor", "red") won't work, document.body.setAttribute("bgColor", "red") does work, and so on.
IE does not differenciate between DOM Core and DOM HTML in this aspect. Setting the attribute with elementnode.setAttribute("AttriBute", ...) has to use the same spelling as the direct, DOM HTML specific method elementnode.AttriBute.

2 Posted by Lars-Erik H on 18 October 2005 | Permalink

The setAttribute() method has a third optional parameter (iFlags), if iflags is set to zero, the attribute name is case-insensitive.
Read more at http://msdn.microsoft.com/library/

3 Posted by netdragon on 23 February 2006 | Permalink

Lars: Microsoft added that third parameter in their own implementation, breaking the standard. Be careful when using it. You'll have to know the browser is IE.