Try
<script type="text/javascript" language="javascript">
var counter = 10; var timerId;
timerId = setInterval("ShowAlert()", 1000);
function ShowAlert() {
if (counter != 0) {
alert(counter);
counter = counter - 1;
}
else {
clearInterval(timerId);
}
}
</script>