Дело было вечером - делать было нечего.
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
body{
background-color: #D2B48C;
}
</style>
</head>
<body>
<script type="text/javascript">
function Blinker(element, color, frames, duration) {
if(element instanceof Node) {
this._color = color;
this._duration = Math.max(+duration, 0) || Blinker.DEFAULT_DURATION;
this._element = element;
this._frames = Math.max(+frames, 1) || 1;
this._currentFrame = this._frames * 2;
this._originalColor = element.style.backgroundColor || '';
}
else {
throw new Error('"Element" is not a "Node"');
}
};
Blinker.prototype = {
isPlayed: false,
onEnd: null,
onEnterFrame: null,
changeFrame: function() {
this._element.style.backgroundColor = this._currentFrame % 2 ? this._originalColor : this._color;
this.dispatchEvent('onEnterFrame');
if(!--this._currentFrame) {
this.stop();
this.dispatchEvent('onEnd');
}
},
dispatchEvent: function(eventName) {
if(typeof this[eventName] == 'function') {
this[eventName]();
}
},
start: function(newDuration) {
if(this.isPlayed) {
this.stop();
this.isPlayed = true;
}
this._intervalID = setInterval(this.changeFrame.bind(this), this._duration);
},
stop: function() {
clearInterval(this._intervalID);
this.isPlayed = true;
this._element.style.backgroundColor = this._originalColor;
}
};
Blinker.DEFAULT_DURATION = 1000;
var blinker = new Blinker(document.body, '#FF0AD4', 10, 500);
blinker.start();
</script>
</body>
</html>