자바스크립트
window.open(URL,name,specs,replace)
사라링
2012. 6. 5. 15:02
Window open() Method
Definition and Usage
The open() method opens a new browser window.
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:
|
||||||||||||||||||||||||||||
specs | Optional. A comma-separated list of items. The following values are supported:
|
||||||||||||||||||||||||||||
replace | Optional.Specifies whether the URL creates a new entry or
replaces the current entry in the history list. The following values are
supported:
|
Browser Support
The open() method is supported in all major browsers.
Examples
Example 1
The following example opens www.w3schools.com in a new browser window:
<html>
<head>
<script type="text/javascript">
function open_win()
{
window.open("http://www.w3schools.com")
}
</script>
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()" />
</body>
</html>
<head>
<script type="text/javascript">
function open_win()
{
window.open("http://www.w3schools.com")
}
</script>
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()" />
</body>
</html>
Try it yourself »
Example 2
The following example opens an about:blank page in a new browser window:
<html>
<body>
<script type="text/javascript">
myWindow=window.open('','','width=200,height=100')
myWindow.document.write("<p>This is 'myWindow'</p>")
myWindow.focus()
</script>
</body>
</html>
<body>
<script type="text/javascript">
myWindow=window.open('','','width=200,height=100')
myWindow.document.write("<p>This is 'myWindow'</p>")
myWindow.focus()
</script>
</body>
</html>
Try it yourself »