Your code doesn't look quite right -- why are you calling setAtribute() twice? Why are you using the return value from your inner setAttribute() call as the first parameter to your outer setAttribute() call? Also -- your parens aren't matching up either. Finally, your HTML button is also not syntactically correct. You use double-quotes to encapsulate your onClick attribute value, but you also use double-quotes within that string for the parameter to alert().
The first double-quote will end the string, and the rest of the stuff is garbage to the HTML parser. More specifically:
onclick="alert("
is your attribute value, and
ello")"
is garbage.
Setting attributes is usually browser-dependant, especially for built-in attributes. It's possible that some browsers expect you to set "onClick", and others expect "onclick", etc... Slight variations in spelling might affect the outcome.
For IE, I find that it's easier just to rewrite the innerHTML attribute:
document.getElementById("but").innerHTML = "<input type=\"button\" id=\"but\" onClick=\"alert('Hello')\">";
I strongly suggest searching the net for other tutorials and examples:
http://www.google.com/search?q=javas...ribute+onClick
Take care,
Nik
http://www.bigaction.org/