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
teenashahAsked:
Who is Participating?
 
Gurvinder Pal SinghConnect With a Mentor Commented:
Yes, thats what is seems and the expert-exchange link i posted earlier seems to confirm that.
However, i have noticed that on my machine on IE8
1) when i click on the maximize button, this code works
2) when i resize from left side, this code works
3) when i resize from right side, this code does not works
0
 
Gurvinder Pal SinghCommented:
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
0
 
teenashahAuthor Commented:
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.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Gurvinder Pal SinghCommented:
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>
0
 
teenashahAuthor Commented:
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?
0
 
teenashahAuthor Commented:
Yes, it seems to be right solution
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.