Skip to content

Instantly share code, notes, and snippets.

@mickaelandrieu
Created September 2, 2013 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mickaelandrieu/6410699 to your computer and use it in GitHub Desktop.
Save mickaelandrieu/6410699 to your computer and use it in GitHub Desktop.
Faire clignoter un onglet de navigateur
<script type="text/javascript">
/* variables à paramétrer */
var texteAlert='!!! New Message !!!';
var periodeTest= 0.5;
var periodeWink= 0.5;
var arretAuto= 60;
var numFrame= 0;
/* code à ne pas trop toucher sans s'y connaitre */
while(parent.frames[numFrame]&&numFrame<7)numFrame++; if(numFrame<7&&navigator.appName!='Microsoft Internet Explorer'&& document.getElementById('i_icon_mini_logout')){var oldCCB;var oldDCB;var pageTitle=document.title; var INTCB;function stopINT(){ if(INTCB!=undefined){clearInterval(INTCB);document.title=pageTitle;} return true;} function checkCB(){ if(parent.frames[numFrame].connected){ parent.frames[numFrame].document.getElementById('refresh_auto').checked=true; var newDCB= parent.frames[numFrame].document.getElementById('chatbox').childNodes[ parent.frames[numFrame].document.getElementById('chatbox').childNodes.length-1].firstChild.innerHTML; if(newDCB!=oldDCB){oldDCB=newDCB;var newCCB= parent.frames[numFrame].document.getElementById('chatbox').childNodes[ parent.frames[numFrame].document.getElementById('chatbox').childNodes.length-1].childNodes[2].innerHTML; stopINT();if(newCCB!=oldCCB){ oldCCB=newCCB;INTCB=setInterval("document.title=(document.title==pageTitle)?texteAlert:pageTitle;",periodeWink*1000); setTimeout('stopINT()',arretAuto*1000);}}}else {stopINT();}} window.onload=function() { oldDCB= parent.frames[numFrame].document.getElementById('chatbox').childNodes[ parent.frames[numFrame].document.getElementById('chatbox').childNodes.length-1].firstChild.innerHTML;oldCCB= parent.frames[numFrame].document.getElementById('chatbox').childNodes[ parent.frames[numFrame].document.getElementById('chatbox').childNodes.length-1].childNodes[2].innerHTML; setInterval('checkCB()',periodeTest*1000); parent.frames[numFrame].onfocus= parent.frames[numFrame].onkeypress= parent.frames[numFrame].onclick= parent.frames[numFrame].onblur=stopINT;}}
</script>
@axinit
Copy link

axinit commented Nov 13, 2015

Hello,
j'ai du mal à faire fonctionner le script, ne sachant à quel chat il se rapporte...
J'imagine que je dois construire les quelques éléments appelés par getElementById, ce que j'ai fait, mais rien ne bouge. De plus comme je dois coder pour Chrome (sic) qui ne gère pas proprement le window.focus/blur, je suis un peu perdu.
Merci d'avance pour quelques éclaircissements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment