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)
}