When I am using javascript to add a node to the DOM, I am going to need to set the onFocus attribute that will call another javascript function.
As you can see below most of the attributes are set using setAttribute, but there are a couple where I needed to use getElementById to work in IE. As you can also see I am using setAttribute to set the onFocus attribute that calls the passwordElement() function. This works well in FireFox but does not work in IE. Any ideas how I can get this to work in both browsers
inputElement.setAttribute("value","foo");
inputElement.setAttribute("type","text");
inputElement.setAttribute("onFocus","passwordElement()");
document.getElementById("password-span").appendChild(inputElement);
document.getElementById("password").className = "regtextbox";
document.getElementById("password").maxLength = "20";
As you can see below most of the attributes are set using setAttribute, but there are a couple where I needed to use getElementById to work in IE. As you can also see I am using setAttribute to set the onFocus attribute that calls the passwordElement() function. This works well in FireFox but does not work in IE. Any ideas how I can get this to work in both browsers
inputElement.setAttribute("value","foo");
inputElement.setAttribute("type","text");
inputElement.setAttribute("onFocus","passwordElement()");
document.getElementById("password-span").appendChild(inputElement);
document.getElementById("password").className = "regtextbox";
document.getElementById("password").maxLength = "20";