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 |
<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>