So I had this need.. to make an HTML popup containing a SWF (scaled to 100% & 100%) that would allow the user to scale the browser window small and large and therefore scale the SWF. The problem was I also needed to make it so that there was a minimum size for the browser window. What I needed was something that would force the browser window to snap back to a minimum size like 600x400 if they resized it down to say 100x100.

It seems so simple in JavaScript.. you know, check the current size of the browser window and if it's too small then resize it back to a larger size. Simple!

But nothing is simple once Microsoft gets ahold of it, and so this is.

Here are the resources I dug up:
force window min size
Maintain Window aspect ration onResize
Manipulating Windows

So it seems simple enough, and within a few minutes I had the code working when I tested in Firefox. I tested in IE6 on my PC and it worked. Cool enough, that was quick.

Then I tried it on my laptop. It didn't work. Here's the Microsoft reason why..
"Windows blocks these functions by using a script when the mouse button is down. If the mouse button is down, Windows considers the operation to be a drag operation and blocks any move or resize functions. "

So essentially what was happening was the user (me) was dragging the browser window in and out and JavaScript was constantly firing an onResize event. IE was interpreting that as some hacker trick or something I guess and so threw an error and walked away. Wee.
Even though my pc is patched up to service pack 2 and I have IE6 all patched up the laptop apparently has something slightly different in the XP. When I check the version for both IE browsers they're the same. The security settings are the same. I was loading via the same server for both systems. But there's something slightly different with the laptop. I didn't have time to dig around and find exactly what is different because it didn't matter. What mattered was I had two computers running XP SP2 and IE6 with the same version and they were treating my JavaScript differently.

So a solution? There's probably a good one out there somewhere, but I didn't find one.. so here's what I did - added a 200ms timeout so that the last reSizeOuterTo() didn't fire until after the mouse button was released. It might be better to use a try/catch and if that error gets thrown then set a short timeout and try again.. or something.. but I just mashed together code I found like so:

function checkSize(){
var width;
var height;
if(document.layers) {
width = window.innerWidth;
height = window.innerHeight;
} else {
width = document.body.clientWidth;
height = document.body.clientHeight;
}
if((width < 600)||(height < 450)){
setTimeout("resizeOuterTo(600,450)",200);
}
}
function resizeOuterTo(w,h) {
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
top.outerWidth=w;
top.outerHeight=h+40;
} else{
top.resizeTo((w+12),(h+30));
}
}
}



It's not elegant, but did the trick for what I needed.. I'm still looking for a permanent solution, so if you have one please feel free to comment.


also.. just to make sure people know this is kind of futile because some dude with a pimped out Firefox might decide to change this setting: