• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 749
  • Last Modified:

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
0
teenashah
Asked:
teenashah
  • 4
  • 3
1 Solution
 
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
 
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
 
Gurvinder Pal SinghCommented:
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
 
teenashahAuthor Commented:
Yes, it seems to be right solution
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now