Main Page

equivalent to IE

oEvent.isChar = (oEvent.charCode > 0);
oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
oEvent.pageY = oEvent.clientY + document.body.scrollTop;
oEvent.preventDefault = function () {
this.returnValue = false;
};
if (oEvent.type == “mouseout”) {
oEvent.relatedTarget = oEvent.toElement;
} else if (oEvent.type == “mouseover”) {
oEvent.relatedTarget = oEvent.fromElement;
}
oEvent.stopPropagation = function () {
this.cancelBubble = true;
};
}
return oEvent;
};
Up next is the
target
property, which is exactly equivalent to IE’s
srcElement
property:
EventUtil.formatEvent = function (oEvent) {
if (isIE && isWin) {
oEvent.charCode = (oEvent.type == “keypress”) ? oEvent.keyCode : 0;
oEvent.eventPhase = 2;
oEvent.isChar = (oEvent.charCode > 0);
oEvent.pageX = oEvent.clientX + document.body.scrollLeft;
oEvent.pageY = oEvent.clientY + document.body.scrollTop;
oEvent.preventDefault = function () {
this.returnValue = false;
};
if (oEvent.type == “mouseout”) {
oEvent.relatedTarget = oEvent.toElement;
} else if (oEvent.type == “mouseover”) {
oEvent.relatedTarget = oEvent.fromElement;
}
oEvent.stopPropagation = function () {
this.cancelBubble = true;
};
oEvent.target = oEvent.srcElement;
}
return oEvent;
};
For the
time
property, you just create a
Date
object with the current date/time and get the milliseconds:
EventUtil.formatEvent = function (oEvent) {
if (isIE && isWin) {
oEvent.charCode = (oEvent.type == “keypress”) ? oEvent.keyCode : 0;
298
Chapter 9
12_579088 ch09.qxd 3/28/05 11:39 AM Page 298


JavaScript EditorFree JavaScript Editor     Ajax Editor


©