Misterdark,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Lesson 9</title>
<style>
</style>
<script>
var $click=0;
var $dblclick=0;
var $mouseover=0;
var $mouseout=0;
var $mouseenter=0;
var $mouseleave=0;
var $mouseup=0;
var $mousedown=0;
var $contextmenu=0;
var $keydown=0;
var $keyup=0;
var $keypress=0;
var $change=0;
var $focus=0;
var $blur=0;
var $tim1;
var $tim2;
function ShowAll()
{ document.getElementById('div2').innerHTML='click: '+$click+'<br>'+
'dblclick: '+$dblclick+'<br>'+
'mouseover: '+$mouseover+'<br>'+
'mouseout: '+$mouseout+'<br>'+
'mouseenter: '+$mouseenter+'<br>'+
'mouseleave: '+$mouseleave+'<br>'+
'mousedown: '+$mousedown+'<br>'+
'mouseup: '+$mouseup+'<br>'+
'contextmenu: '+$contextmenu+'<br><hr>'+
'keydown: '+$keydown+'<br>' +
'keyup: '+$keyup+'<br>' +
'keypress: '+$keypress+'<br>'+
'change: '+$change+'<br>'+
'focus: '+$focus+'<br>'+
'blur: '+$blur+'<br>';
}
function my_click($event) {
$mouseover++;
$mouseout++;
$mouseenter++;
$mouseleave++;
$dblclick++;
$mousedown++;
$contextmenu++;
$keyup++;
$keydown++;
$click++;
$keypress++;
$change++;
$focus++;
$blur++;
$mouseup++;
}
function bgcolor() {
document.getElementById('div2').style="background-color:yellow;"
}
function single_tim($event) {
$tim1=setTimeout(bgcolor,5000);
$event.preventDefault();
}
function tick(event) {
my_click(event);
ShowAll();
$tim2 = setTimeout(tick, 1000);
}
</script>
</head>
<body>
<div id="div1" style="border: 1px solid black;">
<input type="button" id="inp1" value="Запустить интервальный таймер" onClick="$tim2 = setTimeout(tick, 1000);">
<input type="button" value="Остановить интервальный таймер" onClick="clearTimeout($tim2)">
<input type="button" id="inp2" value="Запустить одиночный таймер(через 5 сек)" onClick="single_tim(event)">
<input type="button" value="Остановить одиночный таймер" onClick="clearTimeout($tim1)">
</div>
<div id="div2" style="border: 1px solid black;">
</div>
</body>
</html>