window.open()
- 윈도우를 새로 열고 웹 페이지를 출력한다.
예) window.open("http://www.naver.com","","");
- 3개의 매개변수를 가진 함수
- 윈도우 이름(sWindowName)
- 윈도우 열기 사례
1. myWin 이름에 툴바만 가지는 새 윈도우를 열고 sample.html 을 출력한다.
window.open("sample.html","myWin","toolbar=yes");
2. 현재 윈도우에 sample.html을 출력한다.
window.open("sample.html","_self");
3. 이름 없는 새 윈도우에 sample.html을 출력한다.
window.open("sample.html","_blank");
4. (10, 10) 위치에 300x400 크기의 새 윈도우를 열고 네이버 페이지를 출력한다.
window.open("http://www.naver.com");
window.open("http://www.naver.com",null, "");
5. 빈 윈도우를 생성한다.
window.open(); / window.open(""); / window.open("","",""); / window.open("", null, null);
- 이름 없는 윈도우 열기
버튼을 클릭할 때마다 새 윈도우를 열고 네이버 사이트 출력
<button onclick="window.open('http://www.naver.com'.",'width=600, height=600')"> 새 윈도우 열기
</button>
- 이름을 가진 윈도우 열기
<button onclick="window.open('http://naver.com', 'mywin','width=600, height=600')">새 윈도우 열기
</button>
① my win 이름의 윈도우가 열려 있지 않은 경우 : 버튼을 클릭하면, myWin 이름의 새 윈도우를 열구 네이버를 출력한다.
② myWin 이름의 윈도우가 이미 열려 있는 경우 : 버튼을 클릭하면, 이미 열려있는 myWin이름의 윈도우에 네이버를 출력한다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
function load(url){
//window = new Window();
window.open(url, "myWin", "left=300, top=100, width=400, height=300");
}
</script>
</head>
<body>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'화면구현' 카테고리의 다른 글
웹 페이지 스크롤 (0) | 2020.03.16 |
---|---|
window 객체의 타이머 활용 (0) | 2020.03.16 |
계산기 만들기 (0) | 2020.03.12 |
라디오버튼과 체크박스 (0) | 2020.03.12 |
onblur와 onfocus (0) | 2020.03.12 |