本帖最后由 c442409110 于 2010-01-04 21:38:56 编辑

解决方案 »

  1.   

    document.write重写了输出流,页面内所有的内容都被清除了,自然不会有function abc(),也就不会显示ABC了,改为:<html> 
      <head></head> 
      <body> 
      </body> 
    </html> <script   type= "text/javascript "> 
      document.write('<input name="Button" onclick="abc()" type="button" value="打开" />'
    };   function abc() 
      { 
        document.write('ABC');
      } </script> 就可以了
      

  2.   

    你不能document.write啊。你可以在页面放入一个div。然后把这个<input   name=Button   onClick= "abc() "   type=button   value=打开> 加入到div里。document.write是输出最头上啊。后面的js都没加载啊。
      

  3.   

    你第一次在message中执行document.write,则相当于重新新建了一个页面,原来的js代码已经不存在了。
    再调用abc方法则报错。
    你这种情况应该用DOM来处理。window.onload=function() {
        var oNewInput = document.createElement('input');
        oNewInput.type = 'button';
        oNewInput.value = '打开';
        oNewInput.onclick = function() {
            var oNewDiv = document.createElement('div');
            oNewDiv.innerText = 'abc';
            document.body.appendChild(oNewDiv);
        };
        document.body.appendChild(oNewInput);
    }