You can save the old onresize function and call that either before or after your custom resize function. An example that should work would be something like this:
var oldResize = window.onresize;
function resize() {
console.log("resize event detected!");
if (typeof oldResize === 'function') {
oldResize();
}
}
window.onresize = resize;
This method can have issues if there are several onresize functions. You could save the old onresize function as part of a closure and call the old one after your function.
function addResizeEvent(func) {
var oldResize = window.onresize;
window.onresize = function () {
func();
if (typeof oldResize === 'function') {
oldResize();
}
};
}
function foo() {
console.log("resize foo event detected!");
}
function bar() {
console.log("resize bar event detected!");
}
addResizeEvent(foo);
addResizeEvent(bar);
When you call addResizeEvent, you pass it a function that you want to register. It takes the old resize function and stores it as oldResize. When the resize happens, it will call your function and then call the old resize function. You should be able to add as many calls as you would like.
In this example, when a window resizes, it will call bar, then foo, then whatever was stored in window.resize (if there was anything).