Reputation: 1
I have some sctipt which I run in the specific browser tab and I'm trying to add some notification once the code 'milestone' is met. Let's say we have a loop where:
for (var i = 0; i < 5; i++) {
//some code here
if (i == 3) {
// when this is met I would like the current tab to start blinking
}
}
Any idea how it could be handled in js script?
Upvotes: 0
Views: 339
Reputation: 33813
What I meant by cycling the document title
was to display some other content in a loop which gives a strobe like effect to the page tab (in Chrom & FF anyway ) - when the tab loses focus this slows but still should help draw the eye to that tab... just an idea
const cycletab=( chr=45, total=100, time=250 )=>{
/*
Flash document title
*/
let title=document.title;
let i=0;
let tx=setInterval(()=>{
if( i >= total && !isNaN( tx ) ) {
document.title=title;
clearInterval( tx );
return false;
}
i++;
document.title=document.title==title ? String.fromCharCode( chr ).repeat( 50 ) : title;
}, time );
};
cycletab();
Upvotes: 1