日期:2014-05-16 浏览次数:20361 次
<html> <head> <title>1111</title> <script> window.onload = function(){ var bt=document.getElementById("but1"); bt.attachEvent("onclick",fy); } function fy(){ alert("点击了一下"); } </script> </head> <body> <input type="button" id="but1" value="点击" > </body> </html>
------解决方案--------------------
<html> <head> <title>1111</title> </head> <body> <input type="button" id="but1" value="点击" /> <script> var bt=document.getElementById("but1"); bt.attachEvent("onclick",fy); function fy(){ alert("点击了一下"); } </script> </body> </html>
------解决方案--------------------
javascript版:
<html> <head> <title>1111</title> <script type="text/javascript"> function ClickEvent() { var bt=document.getElementById("but1"); bt.attachEvent("onclick",fy); } function fy(){ alert("点击了一下"); } window.onload=ClickEvent; </script> </head> <body> <input type="button" id="but1" value="点击" /> </body> </html>