What is the correct (modern) method for tapping into the window resize event that works in Firefox, WebKit, and IE?
and can you turn both scrollbars on/off?
What is the correct (modern) method for tapping into the window resize event that works in Firefox, WebKit, and IE?
and can you turn both scrollbars on/off?
Since you are open to jQuery, this plugin seems to do the trick.
jQuery has a built-in method for this:
$(window).resize(function () { /* do something */ });
For the sake of UI responsiveness, you might consider using a setTimeout to call your code only after some number of milliseconds, as shown in the following example, inspired by this:
function doSomething() {
alert("I'm done resizing for the moment");
};
var resizeTimer;
$(window).resize(function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
Does anyone have a clue on how I could do this from within an iFrame? I tried for example setting:
$(window.top).bind('resize', function () { alert('hi'); });
I have also tried with top.document and other combinations, but none of them seems to work... The problem is that $(window) refers to the iframe and not the browser window.
Does anyone have a solution for this?