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

 
Printer friendly version of the FAQ-JavaScript-Maximize-Browser-Window-To-Screen page


Sponsored links

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Web based bug tracking - AdminiTrack.com
AdminiTrack offers an effective web-based bug tracking system designed for professional software development teams.
Computer Professionals: Are you owed Overtime?
Federal and State Laws may allow computer professionals to collect overtime. Our law firm is experienced, and has initiated class action lawsuits against some of the largest computer companies to collect back pay and overtime. Strictly Confidential.
CSTSOFT Instrumentation .NET & ActiveX Components
A collection of 13 instrumentation .NET/ActiveX/VCL components including Gauge,Knob,LED,Trend etc.

Advertisement



Free Magazine

Free Magazines
eWeek The essential technology information source for builders of e-business.... subscribe now

Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 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 Synchron Data - .NET development.