Webmasterpsb
Webmasterpsb

Reputation: 83

How to change and blink the title of the browser when the user goes to other tab or minimizes the browser?

I want to know how to change the title of the browser and set it to a blinking text when the user opens another tab or just minimizes the browser.

Upvotes: 4

Views: 2879

Answers (1)

Joe Simmons
Joe Simmons

Reputation: 1848

For blinking the title:

var title = document.title;
var intv = window.setInterval(function () {
    document.title = document.title === '' ? title : '';
}, 500);

// call this to stop the blinking
function stopBlink() {
    window.clearInterval(intv);
    document.title = title;
}

As for doing it on tab switch or minimize, maybe running the code on window.onblur would work but I'm guessing it can't be done.

Upvotes: 1

Related Questions