I often use the first arguments to get the event object.
obj.onmousedown=function() {
var event = arguments[0];
var x=event.clientX, y=event.clientY;
}
var event = arguments[0];
var x=event.clientX, y=event.clientY;
}
<div onmousedown="_mousedown(event)"></div>
<script type="text/javascript">
function _mousedown(e) {
var x=e.clientX, y=e.clientY;
}
</script>
<script type="text/javascript">
function _mousedown(e) {
var x=e.clientX, y=e.clientY;
}
</script>
Some other solutions provided:
解決 FireFox 下[使用event很麻煩] 的問題
Firefox中Javascript使用event對象需要注意的問題
IE和Firefox下event亂談
Reference:
Javascript Madness: Mouse Events - a full test of mouse events in modern browsers
Event Key Codes - pretty useful event key codes
JavaScript Event KeyCode Test Page
MDC - event
沒有留言:
張貼留言