How much I dig into JavaScript, I find myself asking that much. For example we have window.onresize
event handler and if I say:
window.onresize
One way of doing it is like this:
function resize() { /* ... */ }
var existing = window.onresize;
window.onresize = function() {
if (existing) {
existing();
}
resize();
}
Or you can use something like jQuery which wraps all that stuff in a much simpler construct:
$(window).resize(function() { /* ... */ });
That automatically handles multiple handlers and stuff for you.