自己解决
应该把buttion.setAttribute("onclick","test()")
换成 buttion.onClick = test;

解决方案 »

  1.   

    buttion.setAttribute("onclick",test) 
    这样不知行不行
      

  2.   


    <body>
      <table> 
      <tr> 
        <td> <td> 
      </tr> 
      <tbody id='td'><div id=a></div></tbody> 
      </table> 
    <SCRIPT LANGUAGE=javascript>
    <!--
    button();
    function button(){ 
      var msg='您点击了按钮[提交]';
      var but = document.createElement("input"); 
      but.setAttribute("type","button"); 
      but.setAttribute("value","提交"); 
     but.setAttribute('onclick',new Function("test('"+msg+"')")); 
     document.getElementById('a').appendChild(but); 

    function test(msg){ 
      alert(msg); 
      } 
    //-->
    </SCRIPT>
    </body>
      

  3.   

    onclick是处理函数,不能通过but.setAttribute("onClick","test()"); 来设置的可以这样but.onclick=test;或者
    ie
    but.attachEvent("onclick",test);ff或者dom 2.0
    but.addEventListener("click",test,false);
      

  4.   

    属性和函数不一样.
    setAttribute是设置属性