Good afternoon, as I'm not good at javascript, so I need the masters here to help me. I'm building a system via a browser for a company. In this system will happen several events, and as I wrote in the title, I need a code so that when the user receives a new message of some event occurred, the browser tab blinks.
I know I can do this with alert
of javascript (I believe), and if I have to do it that way, I would like something simple, and disappear when the user opens that window that is blinking.
I found an example in the "gringa" stackoverflow link , which meets, in parts, this need, as it changes the title and this draws the attention of the user. But I wish there was a way to blink, if there is, of course.
Here is the code I found:
<script type="text/javascript">
(function () {
var original = document.title;
var timeout;
window.flashTitle = function (newMsg, howManyTimes) {
function step() {
document.title = (document.title == original) ? newMsg : original;
if (--howManyTimes > 0) {
timeout = setTimeout(step, 1000);
};
};
howManyTimes = parseInt(howManyTimes);
if (isNaN(howManyTimes)) {
howManyTimes = 5;
};
cancelFlashTitle(timeout);
step();
};
window.cancelFlashTitle = function () {
clearTimeout(timeout);
document.title = original;
};
}());
</script>
Suggestions are most welcome.
Thank you