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)
});
时间: 2024-10-13 23:04:08