1

I wrote this code and works fine in Safari browser....
but in Internet Explorer it works in case of width...
but it's not working if only the height is resized from top end towards downward direction...
I noticed the window is sticked to taskbar when resized this way (see attached image) and this allows to resize the window under the limit ...
Any fix for this??...
help will be greatly appreciated...

var MinimumWindowHeight = 600;
    var MinimumWindowWidth = 1024;
    var resizeTimeout;


    $(window).resize(function () {

    clearInterval(resizeTimeout);
        resizeTimeout = setTimeout(function () {
            try {
                if ($(window).height() < MinimumWindowHeight || $(window).width() < MinimumWindowWidth)
                    window.resizeTo(MinimumWindowWidth, MinimumWindowHeight + 168);
            } catch (e) { }
        }, 50);
    });
Random
  • 3,158
  • 1
  • 15
  • 25
devgal
  • 149
  • 2
  • 15
  • 1
    Could you please add a little more description about the problem you have? – abarisone May 11 '15 at 07:48
  • I note you should separate width and height... because if someone resizes to `599x2048`, you will force the window to be `600x1024`, instead of `600x2048` (because 2048 was not too small !). So do 2 successive `if`, where the 2nd `if` takes into account the 1st potential resize... – Random May 11 '15 at 08:18
  • @abarisone have a screenshot for this issue.. since i dont have 10 reputation so i can not post that... Please have a look on this image [screenshot](http://postimg.org/image/9axuvv3yz/)... – devgal May 11 '15 at 08:28
  • @Random Please explain if possible.. as i did not understood your solution – devgal May 11 '15 at 08:56

1 Answers1

1

try this to separate height and width attributes :

clearInterval(resizeTimeout);
        resizeTimeout = setTimeout(function () {
            try {
                if ($(window).height() < MinimumWindowHeight) {
                    window.resizeTo($(window).width(), MinimumWindowHeight + 168);
                }
                if ($(window).width() < MinimumWindowWidth) {
                    window.resizeTo(MinimumWindowWidth, $(window).height());
                }
            } catch (e) { }
        }, 50);
    });



EDIT 1 :
To log what actually happens :

clearInterval(resizeTimeout);
        resizeTimeout = setTimeout(function () {
            try {
                if ($(window).height() < MinimumWindowHeight) {
                    console.log("last height: " + $(window).height());
                    console.log("new height: " + MinimumWindowHeight + "+ 168");
                    window.resizeTo($(window).width(), MinimumWindowHeight + 168);
                }
                if ($(window).width() < MinimumWindowWidth) {
                    console.log("last width: " + $(window).width());
                    console.log("new width: " + MinimumWindowWidth);
                    window.resizeTo(MinimumWindowWidth, $(window).height());
                }
            } catch (e) { 
                    console.log("an error occured !");
            }
        }, 50);
    });



EDIT 2 :
I see a post about the taskbar problem : https://stackoverflow.com/a/60209/4786273.
Looks like you can't, you have to move the window before resizing to avoid this... you could compute the position instead of (0,0) position.
For this, you can read https://stackoverflow.com/a/3437825/4786273, and screen.height - (MinimumWindowHeight + 168) for the top position of your window.

Community
  • 1
  • 1
Random
  • 3,158
  • 1
  • 15
  • 25
  • it's not working...doing the same thing...please see the screenshot of my issue in my previous comments – devgal May 11 '15 at 09:26
  • I don't really understand your screenshot... what is the red box ? the size (resized by your code) after your resizing under the limit ? – Random May 11 '15 at 09:29
  • Red Box shows that..If window is resized from top to downward...the bottom part of window is sticked to taskbar...the stickness is shown in red box....and this allows to decrease the height of window.....if i am doing vice versa that is decreasing the height from bottom to upward my code works..and window is resized to given values..... – devgal May 11 '15 at 09:39
  • Ok, can you add some logs then please ? i edit answer – Random May 11 '15 at 09:49
  • Also in comparison to my first screenshot...it should not stick taskbar...IT SHOULD Adjust it's height irrespective of taskbar and should go beyond it or behind it like in this [screen shot](http://s1.postimg.org/w0v76w3xb/new.png) – devgal May 11 '15 at 10:43