[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
How_To_JavaScript_Maximize_Browser_Window_To_Screen

How to maximize the browser window to the screen?

This cross-browser example shows how to ensure that the browser window always opens maximized to the screen.

Place this script to the top of your index HTML page.

<script language="JavaScript1.2"> 
top.window.moveTo(0,0); 
if (document.all) 
   { top.window.resizeTo(screen.availWidth,screen.availHeight); } 
else if 
   (document.layers || document.getElementById) 
   { 
   if 
    (top.window.outerHeight < screen.availHeight || top.window.outerWidth < 
screen.availWidth)
     { top.window.outerHeight = top.screen.availHeight; 
       top.window.outerWidth = top.screen.availWidth; } 
   } 
</script>


document.all works for Internet Explorer while document.layers works for Mozilla browsers (NN6+).

top refers to the window that is on top of all other windows in the window object hierarchy.

top.window.moveTo(0,0) will display the top window at these coordinates ie. the upper left corner of the screen.

resizeTo(x,y) will resize the window to the size specified.

availWidth and availHeight are properties of the screen object which can detect the available screen space.

Related threads:
How do I Make a Webpage automatically maximize its screen

JavaScript FAQ

last edited (April 19, 2004) by lillu, Number of views: 3073, Current Rev: 6 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.