HTML DOM Window Object
HTML DOM Window Object
Window Object
The Window object is the top level object in the JavaScript hierarchy.
The Window object represents a browser window.
A Window object is created automatically with every instance of a <body> or <frameset> tag.
IE: Internet Explorer, F: Firefox, O: Opera.
Window Object Collections
Collection Description IE F O
frames[] Returns all named frames in the window 4 1 9
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Syntax
window.open(URL,name,specs,replace)
Parameter Description
URL Optional. Specifies the URL of the page to open. If no URL is specified, a new
window with about:blank is opened
name Optional. Specifies the target attribute or the name of the window. The
following values are supported:
titlebar=yes|no|1|0 Whether or not to display the title bar. Ignored unless the calling
application is an HTML Application or a trusted dialog box. Default is yes
replace
Optional.Specifies whether the URL creates a new entry or replaces the current
entry in the history list. The following values are supported:
true - URL replaces the current document in the history list
--------------------------------------------------------------------------------
Example
<html>
<head>
<script type="text/javascript">
function open_win()
window.open("http://www.w3schools.com")
</script>
</head>
</html>
--------------------------------------------------------------------------------
Example
<body><script type="text/javascript">
myWindow=window.open('','','width=200,height=100')
myWindow.document.write("This is 'myWindow'")
myWindow.focus()
</script></body>
</html>
<html>
<head>
<script type="text/javascript">
function open_win()
window.open("http://www.w3schools.com");
</script>
</head>
<body>
<form>
</form>
</body>
</html>
Open a new window and control its appearance
<html>
<head>
<script type="text/javascript">
function open_win()
window.open("http://www.w3schools.com","_blank","toolbar=yes, location=yes,
directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no,
copyhistory=yes, width=400, height=400");
</script>
</head>
<body>
<form>
</form>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function open_win()
window.open("http://www.microsoft.com/");
window.open("http://www.w3schools.com/");
</script>
</head>
<body>
<form>
</form>
</body>
</html>
<html>
<body>
<script type="text/javascript">
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("This is 'myWindow'");
myWindow.focus();
</script>
</body>
</html>