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 »
'자바스크립트' 카테고리의 다른 글
순수 HTML typing 게임 (0) | 2012.08.16 |
---|---|
자바 스크립트를 이용 할때 꼭 한번 읽어야 할것 (0) | 2012.06.20 |
물고기 소스 (0) | 2012.06.15 |
document.createElement (1) | 2012.06.14 |
event.keyCode 사용 하기. (0) | 2012.06.13 |