我必须归档。一个 HTML:
<!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>
和另一个 JavaScript:
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') ; }
我的脚本在 Firefox、Safari、IE、Chrome 上运行良好。但不适用于 Opera 和某些 Android 浏览器。我的脚本有什么问题?
任何人都可以解决这个问题吗?