버튼(새창만들기,사진띄우기,location.assign)연습.html
1008 Bytes
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
<!DOCTYPE html>
<html lang="ko">
<meta charset="utf-8">
<body>
<button onclick="myFunction()">Try it</button>
<button onclick="myFunction2()">try it </button>
<button onclick="myFunction3()">사진 띄우기 </button>
<button onclick="myFunction4()">네이버로가기 </button>
<div id="id">
안녕하십니까
</div>
<div id="id2">
안녕하세영
</div>
<script>
function myFunction() {
var mywindow = window.open("", "_self", "width=500,height = 300");
mywindow.document.write("<h1>Hello</h1>");
}
function myFunction2() {
var x = document.getElementById("id");
x.innerHTML = "changed";
}
function myFunction3() {
var x = document.getElementById("id2");
x.innerHTML = "<img src=../punch.gif>";
}
function myFunction4(){
location.assign("http://www.naver.com");
}
</script>
</body>
</html>