반응형
알림창
alert
메세지와 확인 버튼 하나로 구성된다.
alert("메세지");
val
입력박스가 있는 알림창. 입력값을 반환한다.
let val = prompt("메시지","초기값");
flag
메시지와 확인, 취소 버튼으로 구성된다. 확인 누르면 true, 취소 누르면 false를 반환한다.
let flag = confirm ("메시지");
예시
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<script type = "text/javascript">
alert("hello javascript~");
let age = prompt ("당신의 나이는?","0"); //입력 받는 창
document.write ("age:"+age+"<br/>");
let flag = confirm ("계속 하시겠습니까?"); //확인 취소 버튼
if (flag == true){
document.write("계속 진행");
}else{
document.write("stop");
}
</script>
</body>
</html>
반응형