본문 바로가기
HTML│CSS│Java Script

html 경고창 , 현재 시간 출력 예제

by 자유코딩 2017. 12. 6.

html 예제

 

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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>콜백함수</title>a
 <script type="text/javascript">
     // 콜백함수 ; 함수를 하나의 자료형처럼 취급
     //           즉 함수를 다른 함수의 매개변수로 사용
     function send_go() {
        setTimeout(function() {
            alert("경고메세지")    ;
        }, 3000);
    }
     
     function send_go2() {
        var now = new Date();
        var s = now.getFullYear()+". " + (now.getMonth()+1)+". "+ now.getDate()+"  "+
                now.getHours()+" : " + now.getMinutes()+" : "+now.getSeconds(); 
        document.getElementById("clock").innerHTML=s;
        
        setTimeout("send_go2()"1000);
    }
 </script>
</head>
<body>
    <h2> 버튼을 클릭하면 3초후에 경고창 나타남</h2>
    <button onclick="send_go()">클릭</button>
    <h2><span id="clock"></span> </h2>
    <button onclick="send_go2()">클릭</button>
</body>
</html>
 
cs

 

버튼을 클릭하면 경고창과 시간이 출력되는 예제입니다.

 

jswoo030@gmail.com으로 질문을 보내시면 빠른 답변을 받으실 수 있습니다.

 

 

 

 

'HTML│CSS│Java Script' 카테고리의 다른 글

html  (0) 2017.12.06
html  (0) 2017.12.06
html 예제  (0) 2017.12.06
html 예제  (0) 2017.12.06
p 태그 id에 자바스크립트 결과 담기  (0) 2017.12.06

댓글