Solution # 1 (Recommended): addEventListener
With addEventListener
you can associate so many event handlers to an element as many as needed:
obj.addEventListener('blur', function() {
alert("2");
}, false);
For compatibility with IE8, you need to use attachEvent
:
if(obj.attachEvent) {
elem.attachEvent('onblur', function(){
alert("2");
});
} else {
obj.addEventListener('blur', function() {
alert("2");
}, false);
}
Of course it is recommended to create a function for this, instead of using inline as in the example above. An example function is in the Tuyoshi Vinicius answer .
Solution # 2: save the previous handler
You can save the previous handler to a variable, assign a new handler, and call the old one from there:
var onBlurOriginal = obj.onblur;
obj.onblur = function() {
alert("2");
onBlurOriginal.call(this);
};