How to Resize to Full Screen in Javascript


JavaScript does not have a way to maximize the window for web browsers. "Maximize," meaning to access the Windows Maximize control to open the window. JavaScript can resize the window, but the whole screen is not covered. It is considered bad Internet etiquette to maximize the window during the initial page load. It is better to code a button that will maximize the window when it is clicked, or to have a message telling the user to press the "F11" key to maximize the browser window.

Open Window

  • Create the function you will call to open the full-screen window. In this example we will call the function, "Max_window()." Type the code as follows:


    function Max_window(){





  • Locate the area in the program to call the function.

  • Type "Max_window()" to call the function you created.

Open Window on Page Load

  • Open your HTML editor of choice.

  • Type the code below the <HEAD> tag as follows:

    <script language="JavaScript">

    window.onload = Max_window;

    function Max_window()



    if (document.all)




    else if (document.layers||document.getElementById)


    if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth)


    top.window.outerHeight = screen.availHeight;

    top.window.outerWidth = screen.availWidth;





  • Test the code in your browser.

Tips & Warnings

  • The "document.all" works for Interet Explorer. If you want to write the code for FireFox then use "document.layers" instead.

Related Searches


Promoted By Zergnet



You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!