<html> <head> <script type="text/javascript"> function clickButton() { document.getElementById('button1').click() } function alertMsg() { alert("Button 1 was clicked!") } </script> </head> <body onload="clickButton()"> <form> <input type="button" id="button1" onclick="alertMsg()" value="Button 1" /> </form> </body> </html>
编辑上面的文字,按下“查看结果”,效果会显示在右边 Create by 软晨网(RuanChen.com)