Using Multiple "buttons" Elements in IE6
IE6下点击类型为submit的Button,其他未点击的button也会提交,导致某些程序有问题,下面是一种解决办法。
Save this as buttonfix.js
function buttonfix() { var buttons = document.getElementsByTagName('button'); for (var i=0; i<buttons.length; i++) { if(buttons[i].onclick) continue; buttons[i].onclick = function () { for(j=0; j<this.form.elements.length; j++) if( this.form.elements[j].tagName == 'BUTTON' ) this.form.elements[j].disabled = true; this.disabled=false; this.value = this.attributes.getNamedItem("value").nodeValue ; } } } window.attachEvent("onload", buttonfix);
On each page which you need the fix, include the following:
<!--[if lt IE 7]> <script type="text/javascript" src="buttonfix.js"></script> <![endif]-->
If the problem is also present in IE7, instead use:
<!--[if IE]> <script type="text/javascript" src="buttonfix.js"></script> <![endif]-->