Code for window flap / window / browser tab

0

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

    
asked by anonymous 18.04.2016 / 20:30

1 answer

3

Friend I believe you will not be able to do the effect you want. One tip is to use desktop notifications, take a look at this plugin link . Once the user allows the notifications, he starts receiving messages on the desktop even with the browser minimized. I use it this way and my users liked it.

I'll look for other plugins, if I know of something put to you.

    
19.04.2016 / 05:11