본문 바로가기

프로그래밍

JavaScript - 지정된 시간후 스크립트 실행 setTimeout("함수명()",1000);

출처 : http://devnote7.tistory.com 

* 사용법
setTimeout("함수명()",시간[1/1000초]);

* 예제
<html>
<head>
<script type="text/javascript" language="javascript">
function test(){
    alert("Hello!!!!!");
}
</script>
</head>
<body>
<input type="button" value="버튼 Default" onclick="javascript:test();">
<input type="button" value="버튼 1초" onclick="javascript:setTimeout('test()',1000);">
<input type="button" value="버튼 2초" onclick="javascript:setTimeout('test()',2000);">
</body>
</html>

* 결과