var titleDefault = document.title;
titleChange = '999999999';
window.onblur = function () {
var timerId = setTimeout(function tick() {
if (document.title == titleDefault) {
document.title = titleChange;
}
else {
document.title = titleDefault;
};
timerId = setTimeout(tick, 500);
}, 500);
};
window.onfocus = ???
var changeTitle = function() {
this.title = function () {
var title = document.title;
document.title = (title == "hello" ? "" : "hello");
}
};
changeTitle.prototype.start = function() {
this.timer = setInterval(this.title, 1000);
};
changeTitle.prototype.stop = function() {
clearInterval(this.timer)
};
var timerTitle = new changeTitle();
window.onblur = function() {
timerTitle.start();
};
window.onfocus = function() {
timerTitle.stop();
};