Link to home
Start Free TrialLog in
Avatar of teenashah
teenashah

asked on

Maintain minimum width and height of browser window when resizing

Hi,

I want resize browser window to 1000x700 pixel by default on load of html page. Also whenever you resize window the minimum dimension 1000x700 should be maintained. I tried

window.onresize = function(){
    window.resizeTo(1000,700);
};

but in IE8 its not working giving error "Access denied", however in FF its work fine.

Please guide me with some alternate solution that can be handled using JavaScript
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

on the onresize event of the window you can check the screenX and screenY properties of the window.
if it is lesser than certain value, invoke window.resizeTo(minwidth, minheight);
http://www.javascriptkit.com/jsref/window.shtml
Avatar of teenashah
teenashah

ASKER

Hi gurvinder372,
 In my question onlly i am applying fixed height and width on resize event of window. It works some how in FF but not in IE8.
this code is working fine on my machine
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
      <script>
            function resizeWindow()
            {
                  window.resizeTo(100,100);
            }
      </script>

</HEAD>

<BODY BGCOLOR="#FFFFFF" onload='resizeWindow()'>
      
</BODY>
</HTML>
Hi gurvinder372;

Thanks for quick response. You code perfectly works, when i tried on other's machine. So onlaod event of body browser resizes to given dimension. But when onresize is getting fired with resizeto function IE8 gives "Access denied" error. Is it because of Ie not allowing this methode to execurte?
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, it seems to be right solution