Set browser dimension through JavaScript

In this blog, I would like to demonstrate to open a browser window by choosing particular width and height through JavaScript.

These are the steps for implantation.

1.    Create one aspx file for writing the code.

2.    Paste the script that I appended below .

 

<script language="JavaScript" type="text/javascript">

 function regular() {

 window.open('window-sizer.html', '640x480', 'toolbar=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,directories=yes,width=640,height=480')

        }

 

 function large() {

 window.open('window-sizer.html', '800x600', 'toolbar=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,directories=yes,width=800,height=600')

        }      

 

 </script> 

 

3.    Paste this code in between the <body> tag

 

  <form>

    Open a window 640 x 480 pixels:

    <input type="BUTTON" value="640x480" onclick="regular()">

    <p>

        Open a window 800 x 600 pixels:

        <input type="BUTTON" value="800x600" onclick="large()">0

    <p>

    <p>

        Close this Window:

        <input type="BUTTON" value="Close" onclick="window.close()">

    </form> 

 

And finally run the application to view this page.