0
신고해야합니다. 한 HTML :JavaScript로 이벤트를 감지하는 방법은 무엇입니까?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
<title>JavaScriptSolution</title>
<script src='./script.js' charset='utf-8' defer='defer'></script>
</head>
<body>
<input id='A1' value='On Keydown' style='width:100px; height:50px; margin:30px;'/>
<input id='A2' value='On Keyress' style='width:100px; height:50px; margin:30px;'/>
<input id='A3' value='On Keyup' style='width:100px; height:50px; margin:30px;'/>
<input id='A4' value='On Focus' style='width:100px; height:50px; margin:30px;'/>
<input id='A5' value='On Blur' style='width:100px; height:50px; margin:30px;'/>
<div id='A6' style='width:100px; height:50px; margin:30px;'>
On Click
</div>
<div id='A7' style='width:100px; height:50px; margin:30px;'>
On Mouse Move
</div>
<div id='A8' style='width:100px; height:50px; margin:30px;'>
On Mouse Over
</div>
<div id='A9' style='width:100px; height:50px; margin:30px;'>
On Mouse Out
</div>
</body>
</html>
그리고 다른 하나는 자바 스크립트 : 파이어 폭스, 사파리, IE, 크롬에
function byid(id_name)
{
return document.getElementById(id_name);
}
byid('A1').onkeydown=function a1(){ alert('On Keydown'); }
byid('A2').onkeypress=function a2(){ alert('On Keypress') ; }
byid('A3').onkeyup=function a3(){ alert('On Keyup') ; }
byid('A4').onfocus=function a4(){ alert('On Focus'); }
byid('A5').onblur=function a5(){ alert('On Blur') ; }
byid('A6').onclick=function a6(){ alert('On Click') ; }
byid('A7').onmousemove=function a7(){ alert('On Mouse Move') ; }
byid('A8').onmouseover=function a8(){ alert('On Mouse Over') ; }
byid('A9').onmouseout=function a9(){ alert('On Mouse Out') ; }
내 스크립트 작업 좋아요. 하지만 Opera에서 작동하지 않았습니다. & 일부 Android 브라우저. 내 스크립트의 문제점은 무엇입니까?
누구든지이 문제를 해결할 수 있습니까?
Opera에서 콘솔을 확인 했습니까? –
'window.onload = function() {...};' –
@ShadowWizard : 질문자는 '지연'으로 인해 필요하지 않게 될 것이라고 기대할 것입니다. 왜 필요한지에 대한 설명이 좋습니다. –