Internet Explorer 7 does not handle buttons correctly since it sends the text between <button> and </button>rather than the value. (Weird but true.) This Javascript is supposed to correct this by sending the value of the button onClick. But it does not work. Can anybody see the error ?

I use this to attach the Javascript file in HTML5 :

Code:
<script src="buttonfix.js"></script>
Contents of buttonfix.js :

Code:
function runonclick()
{
    var count = 0;
    var formlength = this.form.elements.length;
    while(count < formlength)
    {
        if(this.form.elements[count].tagName.toLowerCase() == "button")
        {
            this.value = this.attributes.getNamedItem("value").nodeValue;
        }

        count++;
    }
}

function buttonfix()
{
    var buttonarray = document.getElementsByTagName("button");

    var count = 0;
    var buttonarraylength = buttonarray.length;
    while(count < buttonarraylength)
    {
        buttonarray[count].onClick = runonclick();

        count++;
    }
}

window.attachEvent("onload", buttonfix());