Javascript Window Object
The window object is supported by all browsers. It represents the browser's window.

There are three types of window objects:

1. collection : The window object collection is a set of all the window objects available in an HTML document.

2. properties : All data and information about any browser is attached to the window object as properties and the frames property in the window object returns all the frames in the current window. 

3. methods : Window object methods are enable to you perform various tasks such as open a url in a new window or to close a window. The following table describes the methods of the Window object in JavaScript.
Method Description
open() opens a new browser window
close() closes the current window
moveTo() moves a window to an specified position
resizeTo() resizes a window with the specified width and height
confirm() displays a dialog box with a message and two buttons, OK and Cancel
alert() displays an alert box with a message and an OK button
scrollTo() scrolls the content of a window up to the specified coordinates
Example Program :
<html>
<head>
<title>JavaScript Window Object Methods</title>
 
<script type="text/javascript">
var mywin;
function openMidWin(url)
{
var wid = 600;
var hei = 200;
var winFeat = "width = " + wid + ", height = " + hei + " , status, resizable";
myWin = window.open(url, "subWind", winFeat);
}
function disp_alert()
{
alert("Hi, This is an alert box.");
}
function resize_win()
{
window.resizeBy(-100, -100)
}
function close_win()
{
if(window.confirm("Are you close this window ?"))
window.close();
}
</script>
 
</head>
<body>
 
<h3>JavaScript Window Object Methods :</h3>
 
<input type="button" value="Open New Window" onclick="openMidWin('javascript-window-objects.php')" />
<input type="button" value="Alert" onclick="disp_alert()" />
<input type="button" value="Resize Window" onclick="resize_win()" />
<input type="button" value="Close Window" onclick="close_win()" />
 
</body>
</html>
Output :