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 :
Contents of buttonfix.js :
[code=javascript]
function runonclick()
{
var count = 0;
var formlength = this.form.eleme nts.length;
while(count < formlength)
{
if(this.form.el ements[count].tagName.toLowe rCase() == "button")
{
this.value = this.attributes .getNamedItem(" value").nodeVal ue;
}
count++;
}
}
function buttonfix()
{
var buttonarray = document.getEle mentsByTagName( "button");
var count = 0;
var buttonarrayleng th = buttonarray.len gth;
while(count < buttonarrayleng th)
{
buttonarray[count].onclick = runonclick;
count++;
}
}
window.attachEv ent("onload", buttonfix);
[/code]
I use this to attach the Javascript file in HTML5 :
Code:
<script src="buttonfix.js"></script>
[code=javascript]
function runonclick()
{
var count = 0;
var formlength = this.form.eleme nts.length;
while(count < formlength)
{
if(this.form.el ements[count].tagName.toLowe rCase() == "button")
{
this.value = this.attributes .getNamedItem(" value").nodeVal ue;
}
count++;
}
}
function buttonfix()
{
var buttonarray = document.getEle mentsByTagName( "button");
var count = 0;
var buttonarrayleng th = buttonarray.len gth;
while(count < buttonarrayleng th)
{
buttonarray[count].onclick = runonclick;
count++;
}
}
window.attachEv ent("onload", buttonfix);
[/code]
Comment