mirror of
https://github.com/berkeleydb/libdb.git
synced 2024-11-16 17:16:25 +00:00
23 lines
685 B
JavaScript
23 lines
685 B
JavaScript
|
|
// attach a handler to a particular event on an element
|
|
// in a browser-independent way
|
|
function registerEventHandler (element, event, handler) {
|
|
if (element.attachEvent) {
|
|
// MS registration model
|
|
element.attachEvent('on' + event, handler);
|
|
} else if (element.addEventListener) {
|
|
// NN (W4C) regisration model
|
|
element.addEventListener(event, handler, false);
|
|
} else {
|
|
// old regisration model as fall-back
|
|
element[event] = handler;
|
|
}
|
|
}
|
|
|
|
// get a delegate that refers to an instance method
|
|
function getInstanceDelegate (obj, methodName) {
|
|
return( function(e) {
|
|
e = e || window.event;
|
|
return obj[methodName](e);
|
|
} );
|
|
}
|