Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
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
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter05 : 대화상자 본문

WEB.JS/01.BASIC_JS

chapter05 : 대화상자

GAWON 2023. 5. 19. 09:18
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	/*
		대화 상자
		1. alert("경고 메세지")	 : 경고 메세지를 출력한다.
		2. confirm("확인 메세지") : 사용자에게 확인을 받는다.
			1) 확인 : true
			2) 취소 : false
		3. prompt("입력 메세지", "기본 입력 값") : 사용자에게 입력을 받는다.
	*/
	alert("경고창");

	var result = confirm("계속 진행할까요?");
	document.write("<h3>" + result + "</h3>");

	var a = prompt("숫자를 입력하세요.", "1");
	document.write("<h3>" + a + "</h3>");
	document.write("<h3>" + typeof(a) + "</h3>");	// prompt로 입력 받는 타입은 무조건 string으로 나옴

	// 정수로 입력 받는 방법 : Number, parseInt
	var b = Number(prompt("숫자를 입력하세요."));
	document.write("<h3>" + b + "</h3>");
	document.write("<h3>" + typeof(b) + "</h3>");



</script>
</head>
<body>

</body>
</html>

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

chapter06 : es5_es6  (0) 2023.05.19
chapter04 : 연산자  (0) 2023.05.19
chapter03 : 형변환  (0) 2023.05.19
chapter02 : 기본자료형  (0) 2023.05.19
chapter01 : basic_js  (0) 2023.05.19