2016년 10월 21일 금요일

BOM 정리

alert

경고창이라고 부른다. 사용자에게 정보를 제공하거나 디버깅등의 용도로 많이 사용한다.

2
3
4
5
6

<input type="button" value="alert" onclick="alert('hello world');" />

confirm

확인을 누르면 true, 취소를 누르면 false를 리턴한다.

<input type="button" value="confirm" onclick="func_confirm()" />
<script>
function func_confirm(){
if(confirm('ok?')){
alert('ok');
} else {
alert('cancel');
}
}
</script>

prompt


<input type="button" value="prompt" onclick="func_prompt()" />
<script>
function func_prompt(){
if(prompt('id?') === 'egoing'){
alert('welcome');
} else {
alert('fail');
}
}
</script>

댓글 없음:

댓글 쓰기