<HTML>
<HEAD>
<title>test</title>
<script language="javascript">
function test()
{
var testInput = document.createElement("<input>");
testInput.setAttribute("type","button");
testInput.setAttribute("name","test");
testInput.setAttribute("value", "test");
testInput.setAttribute("onClick","test1()");
Form1.insertBefore(testInput);
return true; 
}
function test1(){
alert("O");
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post">
<INPUT style="Z-INDEX: 101; LEFT: 184px; POSITION: absolute; TOP: 48px" type="button" value="Button" onclick="test();">
</form>
</body>
</HTML>

解决方案 »

  1.   

    <HTML>
    <HEAD>
    <title>test</title>
    <script language="javascript">
    function test()
    {
    var testInput = document.createElement("<input>");
    testInput.setAttribute("type","button");
    testInput.setAttribute("name","test");
    testInput.setAttribute("value", "test");
    testInput.onclick=test1
    Form1.insertBefore(testInput);
    return true; 
    }
    function test1(){
    alert("O");
    }
    </script>
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post">
    <INPUT style="Z-INDEX: 101; LEFT: 184px; POSITION: absolute; TOP: 48px" type="button" value="Button" onclick="test();">
    </form>
    </body>
    </HTML>