Javascript to maximise window on load

Well this is simple script to get your browser maximised onload:


<script language=”JavaScript”>
window.onload = maxWindow;
function maxWindow()
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;



I just tested it it IE. Hope this works fine in other browsers.

You can also open up a new window as maximised. Check the script snippet below:

function fullScreen(theURL) {‘testwindow.html’, ”, ‘fullscreen=yes, scrollbars=auto’);

If you would like to use jQuery here, you can use the following jQuery methods:

var height = $(window).height();
var width  = $(window).width();

Hope this helps.

  1. This Code is not working in other browser like firefox and chrome


Feel free to leave a reply here...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: