1. 程式人生 > >Js高級 事件 對象

Js高級 事件 對象

function bsp defined 客戶 只需要 兼容性 obj click use

1.事件

瀏覽器客戶端上客戶觸發的行為都成為事件

所有的事件都是天生自帶的,不需要我們我去綁定,只需要我們去觸發。

通過obj.事件名=function(){}

事件名:onmouseover onmouseout onmousedown onmousemove onmouseup Onclick onchange onfocus onblur 等等。

當用戶觸發一個事件時,瀏覽器的所有詳細信息都存在一個叫event的對象上。我們把他叫事件對象

所有事件再綁定方法的時候,天生自帶一個參數就叫event。

鼠標的坐標

Event.clientX

Event.clientY

Event的兼容性

在chrome下event是undefined 在Ie低版本下是null,火狐下會報錯

document.onclick=function(e){

var e=e||window.event

}

Js高級 事件 對象