Discussion:
Capture maximize or restore down event in javascript
(too old to reply)
Richa Avasthi
18 years ago
Permalink
Hi, I'm developing a web application where I've got a javascript window
resize event handler that resizes specific content on my page based on the
window size. Unfortunately, it seems that in IE6, when I maximize the
browser window, or restore down after maximizing, the javascript resize event
does not get fired.

My questions are:
1) Is this in fact the case, and
2) What can I do about it if so?

Any help would be deeply appreciated.

Thanks,
Richa
unknown
18 years ago
Permalink
Post by Richa Avasthi
Unfortunately, it seems that in IE6, when I maximize the
browser window, or restore down after maximizing, the javascript resize event
does not get fired.
No, that's not true. The resize event fires in IE (tested on 6) when you
maximize/restore the window.





Good Luck, Ayush.
--
Script Center : http://microsoft.com/technet/scriptcenter/default.mspx
Richa Avasthi
18 years ago
Permalink
After some further investigation, I discovered that the resize event fires 3
times each on a maximize/restore in IE, compared to only once in Firefox.
Could this be causing the problem? Does my resize event handler need to be
threadsafe, since it doesn't seem to complete operation properly when the
window is maximized/restored?
Post by unknown
No, that's not true. The resize event fires in IE (tested on 6) when you
maximize/restore the window.
unknown
18 years ago
Permalink
Post by Richa Avasthi
After some further investigation, I discovered that the resize event fires 3
times each on a maximize/restore in IE, compared to only once in Firefox.
It fires 2 times here. Tested with this -
<body onload="x=0" onresize="document.body.innerHTML=x++">
Post by Richa Avasthi
Could this be causing the problem?
You can easily detect it by comparing the window size
(document.documentElement.offsetWidth) and checking how many times the event fired.


Good Luck, Ayush.
--
Script Center-Script Repository : http://snipurl.com/Script_Repository
Anthony Jones
18 years ago
Permalink
Post by Richa Avasthi
After some further investigation, I discovered that the resize event fires 3
times each on a maximize/restore in IE, compared to only once in Firefox.
Could this be causing the problem? Does my resize event handler need to be
threadsafe, since it doesn't seem to complete operation properly when the
window is maximized/restored?
There is only one thread executing Javascript code so thread safety is not
an issue.

Consider though using an idle timeout to run your code. Eg.:-

var mhResizeTimeout

function onresize()
{
if (mhResizeTimeout) window.clearTimeout(mhResizeTimeout)
mhResizeTimeout = 0
mhResizeTimeout = window.setTimeout(doResizeStuff, 500)
}

function doResizeStuff()
{
mhResizeTimeout = 0
// your code
}

When the user is busy moving things about nothing happens. After they have
left things alone for half a second you'. I think FF takes the view that
your only interested in the resize once the user as released the mouse
button. IE OTH fires resize events as the user drags borders about.
Post by Richa Avasthi
Post by unknown
No, that's not true. The resize event fires in IE (tested on 6) when you
maximize/restore the window.
Continue reading on narkive:
Search results for 'Capture maximize or restore down event in javascript' (Questions and Answers)
4
replies
booting files of computers in window xp?
started 18 years ago
software
Loading...