event.screenX和外部Javascript

event.screenX和外部Javascript,javascript,events,cursor,Javascript,Events,Cursor,我目前正在尝试使用 function getCursor(event) { event.screenX; event.screenY; } 我知道你可以通过使用类似于 但是,我目前正尝试使用纯外部javascript文件,并附加如下事件: element.onmousemove = getCursor //or element.onmousemove = function() {getCursor(parameters)} 如何引用这些函数所附加到的事件? 提前感谢您的帮助

我目前正在尝试使用

function getCursor(event) {
    event.screenX;
    event.screenY;
}
我知道你可以通过使用类似于

但是,我目前正尝试使用纯外部javascript文件,并附加如下事件:

element.onmousemove = getCursor
//or
element.onmousemove = function() {getCursor(parameters)}
如何引用这些函数所附加到的事件?

提前感谢您的帮助

注意:我不使用jQuery或任何其他javascript库

更新
nvm!我明白了。实际上你根本不需要通过参数
element.onmousemove=getCursor
只要您有
函数getCursor(event){}
就可以很好地工作。对不起,给你:

element.onmousemove = function(e) {
    e = e || window.event;    
    getCursor(e);
}
事件对象作为第一个参数自动传递到事件处理程序函数中。Internet Explorer 8及以下版本除外-
e=e | | window.event
也将使其在IE的这些版本中工作

现场演示:给你:

element.onmousemove = function(e) {
    e = e || window.event;    
    getCursor(e);
}
事件对象作为第一个参数自动传递到事件处理程序函数中。Internet Explorer 8及以下版本除外-
e=e | | window.event
也将使其在IE的这些版本中工作


现场演示:
element.onmousemove=getCursor在IE8及以下版本中不起作用…
element.onmousemove=getCursor在IE8及以下版本中不起作用。。。