Skip to content

Instantly share code, notes, and snippets.

@christurnertv
Created September 5, 2014 19:14
Show Gist options
  • Save christurnertv/2f1acecb073560b17d81 to your computer and use it in GitHub Desktop.
Save christurnertv/2f1acecb073560b17d81 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Disarm the BOM (Browser Object Model)</title>
</head>
<body>
<h1>Mission Impossible!</h1>
<button id="btnDisarm">Disarm the BOM!</button>
<script>
var detonationTimer = 10; // seconds
var intervalId = setInterval(function () {
detonationTimer--;
console.log(detonationTimer + '...');
if (detonationTimer == 0) {
alert('BOMMMMM!!!');
clearInterval(intervalId);
}
}, 1000);
var btnDisarm = document.getElementById('btnDisarm');
btnDisarm.addEventListener('click', function () {
clearInterval(intervalId);
alert('You are a hero! You disarmed the BOM!');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment