I’m having trouble getting a script to add an onsubmit attribute to a form in IE. It works fine in Chrome though.
document.getElementsByName('form_name').item(0).setAttribute("onsubmit","add_to_form()");
It is grabbing the element fine and I can use getAttribute to print out pre-existing attributes just fine.
Your document probably puts IE in Quirks Mode, since in Standards Mode, the code seems to work OK.
To make the code work in Quirks Mode too, you can assign to the DOM property
onsubmitrather than the HTML attribute. These two do not necessarily correspond to each other in old versions and Quirks Mode of IE. In your example, use this instead: