Perhaps this is a stupid question, but for some reason it does not work out. There is such an interesting small and fragile library of miss you: https://github.com/Bahlaouane-Hamza/I-Miss-You (github). The bottom line is that when we leave a tab, the title changes to what we want, for example, to i miss you, and you can also change the icon until the user returns.

I find it intrusive to put this in the normal mode, so I would like to make a delay of at least 30 minutes, but I can't do it in the way I can.

<link rel="shortcut icon" href="favicon.ico"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="jquery.iMissYou.js"></script> <script> jQuery(document).ready(function($){ $.iMissYou({ title: "I Miss you !", favicon: { enabled: true, src:'iMissYouFavicon.ico' } }); }); </script> 

Save the doll! I beg you!

  • Judging by the fact that there is no documentation for this plugin, it is not possible to do what you want. The only way out is to open the source code of the plugin and rewrite it. - Anatoly Shevelev
  • Is it impossible to put any delay on $ .iMissYou? - Igor
  • No, because the listener is replaced by a tab inside $.iMissYou(); - Anatoly Shevelev
  • Sorry, Anatoly, but you do not know if there is any alternative to do the same as here, but with your own hands or with the help of another library? - Igor
  • added an example to the answer - Anatoly Shevelev

1 answer 1

Judging by the fact that there is no documentation for this plugin, it is not possible to do what you want. The only way out is to open the source code of the plugin and rewrite it.

Put the delay on $.iMissYou(); will not work because The listener is replaced by the plugin by changing the tab ...

You can try to do without the plugin, changing the title can be done something like this:

 <script> window.onblur = function () {document.title='документ неактивен'} window.onfocus = function () {document.title='документ снова активен'} </script> 

And if with a delay, then something like this:

 timerId = null; function func1() { document.title='документ неактивен' } function func2() { document.title='документ снова активен' } window.onblur = function () { clearTimeout(timerId); timerId = setTimeout(func1, 30000); } window.onfocus = function () { clearTimeout(timerId); func2(); } 

It is possible to change the favicon somehow (I'm not sure what will work, I have not tried it myself):

 <link id="favicon" rel="shortcut icon" type="image/png" href="icon1.png" /> $("#favicon").attr("href","icon2.png"); 

Favikonki usually hard-cached, you need to try ...

  • Understood, but how to change the favicon? - Igor
  • Now give an example - Anatoly Shevelev
  • and, before doing the delay, you need to reset the timeout - Anatoly Shevelev
  • Thank you very much!) You saved me straight. I am extremely grateful, really! - Igor
  • In this case you need? - Igor