set Timeoutパラメータ

868 ワード

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">

</head>
<body>

<input type="button" value="ok" onclick="clk('hello')" />

<script type="text/javascript">

	var timeoutID = "";
	function clk(s){
		
		clearTimeout (timeoutID);//      ,           1         
		timeoutID = setTimeout(function(){alert(s)},1000);//  1      
		
		setTimeout(function(){alertMsg(s)},1000);//              
		setTimeout("alertMsg2()",1000);//                  
	}

	function alertMsg(s){
	 alert(s);
	}
	
	function alertMsg2(){
		 alert("msg2");
	}

</script>
</body>
</html>