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 32 33 34 35 36 37 38 39 40
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test</title>
<script type="text/javascript">//<![CDATA[
function setTimepicker(){
alert('interval');
}
// Initialisation de l'objet timePicker
var timePicker=(function(f,d){
var interval,func,delay;
if(typeof f=='function'&& d>0){
func=f;
delay=d;
}
return{
_setInterval:function(){
if(func && delay && !interval)interval=setInterval(func,delay);
},
_clearInterval:function(){
interval && clearInterval(interval);
interval=null;
}
}
})( setTimepicker, // Réference de la fonction appelée à intervalles réguliers
3000 // delai en millisecondes
);
//]]>
</script>
</head>
<body>
<button onclick="timePicker._setInterval()">Start</button>
<button onclick="timePicker._clearInterval()">Stop</button>
</body>
</html> |
Partager