2009年2月13日 星期五

JavaScript Event object

Firefox can not use the event object in JavaScript
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;
}

<div onmousedown="_mousedown(event)"></div>
<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

沒有留言:

Powered By Blogger