1、取随机整数
Math.floor(Math.random(1-100)*100)
2、获取鼠标点击位置
//HTML
<button onclick="site(event)">获取鼠标点击位置</button>
//JS
function site(event){
var x = event.clientX,
var y = event.clientY;
alert("X 坐标: " + x + ", Y 坐标: " + y);
}
3、获取按键Unicode码:
//HTML
<button onkeyup="whichButton(event)">获取Unicode</button>
//JS
function whichButton(event){
alert(event.keyCode)
}