1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
 
 
<script type="text/javascript">
 
    
    //http://koxo.com
    
    //창 제어
    function test() {
        
        //URL : 새창의 주소값
        //name : 자식을 중복으로 허용할지 말지        
        
        //window.open("URL", "name", "option");
        window.open("ex08.htm""new""width=200, height=200, left=0, top=0, resizable=no, scrollbars=no");
        
    }
    
    
    
    /* 부모가 자식 찾기 */
    var child; //제어하려면 child를 전역변수로 빼줘야
    function test2() {
        child = window.open("ex09_child.htm""child""width=200, height=200");
        
    }
        
    function test3() {
    
        //자식창을 접근 -> 제어
        //child.close();
        //window.document.getElementById("txt1").value = "홍길동"; //DOM
        child.document.getElementById("txt1").value= "부모창에서 왔습니다."//***자식창의window객체를 얻음
    }
    
    
    /* 자식이 부모 찾기 */
    function test() {
        //opener.close();    
        //opener.document.getElementById("txt1").value = "자식창에서 접근했니다.";
        
    }
    
 
</script>
 
 
</head>
<body>
 
 
    <!-- ex09.htm -->
    
 
    
    <input type="button" value=" 창띄우기 " onclick="test();" />
    
    
    <hr />[*****]<br />
    <input type="button" value="새창 열기" onclick="test2();" />
    <input type="button" value="자식창 접근하기" onclick="test3();" />
    <br />
    <input type="text" name="txt1" id="txt1" />
    
    
    
    
</body>
</html>
cs



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
 
 
<script type="text/javascript">
 
 
    function test() {
        //부모창 찾기??
        //opener.close();
        //opener.document.getElementById("txt1").value = "자식창에서 접근했습니다.";
        
        opener.document.getElementById("txt1").value = window.document.getElementById("txt1").value;
        window.close();
    }
 
    
</script>
 
 
</head>
<body>
 
 
    <!-- ex09_child.htm -->
    <!-- 자식창으로띄울것 -->
    
    <input type="button" value="테스트"  onclick="test();" />
    <br />
    <input type="text" name="txt1" id="txt1" />
 
 
</body>
</html>
cs


'WEB > JS' 카테고리의 다른 글

태그 검색  (0) 2016.01.22
BOM test  (0) 2016.01.22
BOM / DOM 방식  (0) 2016.01.22
날짜시간 / 배열(array)  (0) 2016.01.22
문자열 / 길이 / 검색 / 치환 / 벼환 / 분할 / 추출 / 제어문  (0) 2016.01.22

+ Recent posts