1. 程式人生 > >鼠標和滾輪事件

鼠標和滾輪事件

client click func eve event screen dha util 客戶

1、可以通過以下代碼取得鼠標事件的客戶端坐標信息;

  var btn = document.getElementById("btn");

  EventUtil.addHandler(btn,"click",function(event){
    event = EventUtil.getEvent(event);
    alert("client coordinates:" + event.clientX+","+event.clientY)
  });

2、可以通過以下代碼取得鼠標事件的頁面坐標信息;

  var btn = document.getElementById("btn");

  EventUtil.addHandler(btn,"click",function(event){
    event = EventUtil.getEvent(event);
    alert("client coordinates:" + event.pageX+","+event.pageY)
  });

3、可以通過以下代碼取得鼠標事件的屏幕坐標信息;

  var btn = document.getElementById("btn");

  EventUtil.addHandler(btn,"click",function(event){
    event = EventUtil.getEvent(event);
    alert("client coordinates:" + event.screenX+","+event.screenY)
  });

鼠標和滾輪事件