Maximizing a window

JavaScript FAQ | JavaScript Windows FAQ  

Question: How do I maximize a window?

Answer: To maximize the browser window, script code can get the available screen size and then resize the window to the user's screen size. Just like the resizeTo() method itself, the example below may or may not work depending on the client browser and its current settings.

Here's the source code:
function maximizeWindow() {
 if (top.moveTo)    
 if (top.resizeTo)  
 if (top.outerWidth)
     top.outerWidth  = screen.availWidth;
 if (top.outerHeight)
     top.outerHeight = screen.availHeight;
A couple of remarks:

1. JavaScript code cannot change the look of the maximize button (the second button in the top right corner of the browser window under Windows operating systems).

2. There was no reliable way to determine the screen size in IE3 or Netscape Navigator prior to version 4 (except for calling Java from Navigator 3.x). Therefore, the example above only works in versions 4 and newer.

Copyright © 1999-2011,