faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

31 of 35 people (89%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Can I prevent a window from being maximized?

Apr 22nd, 2000 06:17
Martin Honnen,


You can capture
  window.onresize
and check the dimensions. If they appear to be maximized resize the 
window as needed:

<HTML>
<HEAD>
<STYLE>
.js {
  font-weight: bold;
  background-color: orange;
  color: white;
}
</STYLE>
<SCRIPT>
var defaultWidth = 300;
var defaultHeight = 300;
window.onresize = function (evt) {
  if ((document.all && document.body.offsetWidth >= screen.availWidth)
      || (window.outerWidth && window.outerWidth >= screen.availWidth))
    window.resizeTo(defaultWidth, defaultHeight);
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE WIDTH="100%" HEIGHT="100%">
<TR>
<TD ALIGN="center" VALIGN="middle">
<A CLASS="js" HREF="http:JavaScript.FAQTs.com">
JavaScript.FAQTs.com
</A>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>