JavaScript:起動して5秒後に処理を実行

JavaScript
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="mystyle.css">
	<title>起動して5秒後に処理を実行</title>
	<script>
		function wa(){
			alert("わ!");
		}
		
		window.addEventListener("load", function(){
			setTimeout(wa, 5000);	// 第2引数はミリ秒単位
		});
		
	</script>
</head>
<body>
	<h1>起動して5秒後に処理を実行</h1>
</body>
</html>

コメント