<html>
<head>
<title>三种加事件的方式</title>
<script language="javascript" type="text/javascript">
window.οnlοad=function(){
var arr = new Array(10);
for(var i = 0; i < arr.length; i ++){
arr[i]=i;
}
document.getElementById("but1").οnclick=function(){
alert("ok");
}
var butAdd2 = document.getElementById("but2");
butAdd2.onclick = function(){
alert("ok");
}
}
function butEvent(){
alert("ok")
}
</script>
</head>
<body>
<input type="button" value="测试1" id="but1"/>
<input type="button" value="测试2" id="but2"/>
<input type="button" value="测试3" id="but3" οnclick="butEvent()"/>
</body>
</html>