임호준

0413자바스크립트 실습

1 +function message(){
2 +
3 +document.write("????");
4 +var d = new Date(300000000);
5 +document.getElementById("demo").innerHTML = d;
6 +
7 +}
1 +<!DOCTYPE html>
2 +<html>
3 + <head>
4 + <meta charset="utf-8">
5 + <title>js</title>
6 + <script type="text/javascript" src = "hello.js"></script>
7 +
8 +
9 + </head>
10 + <body onload="message()" >
11 +
12 +
13 + <script type="text/javascript">
14 +
15 +
16 +
17 +
18 + </script>
19 + <p>hi <hr></p>
20 + <p id="demo">
21 +
22 + </p>
23 + </body>
24 +</html>
1 +<!DOCTYPE html>
2 +<html lang="ko">
3 + <meta charset="utf-8">
4 +
5 +<body>
6 + <button onclick="myFunction()">Try it</button>
7 + <button onclick="myFunction2()">try it </button>
8 + <button onclick="myFunction3()">사진 띄우기 </button>
9 + <button onclick="myFunction4()">네이버로가기 </button>
10 + <div id="id">
11 + 안녕하십니까
12 + </div>
13 + <div id="id2">
14 + 안녕하세영
15 +
16 + </div>
17 +
18 +
19 + <script>
20 + function myFunction() {
21 + var mywindow = window.open("", "_self", "width=500,height = 300");
22 + mywindow.document.write("<h1>Hello</h1>");
23 + }
24 +
25 + function myFunction2() {
26 + var x = document.getElementById("id");
27 + x.innerHTML = "changed";
28 + }
29 +
30 + function myFunction3() {
31 + var x = document.getElementById("id2");
32 + x.innerHTML = "<img src=../punch.gif>"; //src 뒤에 "" 가 오면 이 코드는 ""<img src = .."까지 밖에 인식하지못해 error발생함
33 + }
34 +
35 + function myFunction4(){
36 + location.assign("http://www.naver.com");
37 + }
38 + </script>
39 +
40 +</body>
41 +
42 +</html>
1 +<!DOCTYPE html>
2 +
3 +<html lang="ko">
4 + <head>
5 + <meta charset="utf-8">
6 + <title>123</title>
7 + </head>
8 +
9 + <body>
10 + <button type="button" onclick = "myFunction()" name="button">click this</button>
11 + <div id="div1">
12 + <h1>안녕하세요</h1>
13 + </div>
14 +
15 + <input type="text" name="" value="" id="input1">
16 + <button type="button" onclick="myFunction2()" name="button">click this</button>
17 + <div id="div2">
18 +
19 + </div>
20 + <script type="text/javascript">
21 + "use strict";
22 + function myFunction(){
23 + var name = prompt("Enter your Name", "Name");
24 + var t = document.getElementById("div1");
25 + t.innerHTML = "<h1>"+name+"</h1>";
26 + }
27 + function myFunction2(){
28 + var name = document.getElementById("input1").value;
29 + var div = document.getElementById("div2");
30 + div.innerHTML = "<h1>"+name+"</h1>";
31 + }
32 +
33 +
34 +
35 +
36 + </script>
37 + </body>
38 +</html>