IE 6 Button Bug

Reported 5 October 2005 to Quirks Mode.

The following will throw an exception in IE 6:


var button=document.createElement("button");
button.type="button";

See the bug in action: if you click here, a new button should be appended to the document (and will be on Mozilla). In IE, an error occurs.

(Strangely, if you try to call button.type="button" within a function that supposedly returns the button element, the function will exit and the return type will be set to undefined, but no exception will be thrown!)

In fact, you can see this bug by simply entering the following in your browser: javascript:var button=document.createElement("button");button.type="button";

The only workaround for dynamically creating <button type="button"> seems to be to convert the button HTML to a string and append it to innerHTML, which you can see by clicking here.