Blinking Page Title with Javascript | Flashing HTML page title

April 13, 2011

Now this is a very old practice that was probably popular some 5 years ago. Blinking / flashing your page title. But the thing is that I had to use it yesterday for a chat page. Every time a new message arrives we wanted to catch the users attention. So thats where it helps.

Where can you see the Title text blinking?

  • If you have the page open your Title will blink. Either switch between two messages or One Blank and One Message switching.
  • if you have that page open in a tab the you will see some text blinking on the tab name.
  • If the window is minimised with the page in question as the active tab then you can see the text in the taskbar tab blinking.
  • If you are using windows 7 then you need to point to your browser icon on task bar to see the blinking happening.

Here is the code.


defaultmsg=document.title

// functions to blink the title of the page with a message

function blinkmsg(message, count) {

    blinkingmsg(count, message, true);

}

function blinkingmsg(count, message, blink){

    if(blink){

        document.title=message;

    } else {

        document.title=defaultmsg;

        count-- // decrement the number of times left to blink

    }

    if (count > 0) {

        blinkTimer = setTimeout("blinkingmsg("+count+", '"+message+"', "+!blink+")", 800);

    }

}

function test()

{

setInterval('blinkmsg("drink.", 3)', 2000);

}

Now the above code will do three title flashes in 2000, miliseconds or 2 seconds. So you can do the calculation as per your needs. Do not bug the user too much. Thats not a good idea. Plus setTimeOut will use quite a bit a CPU time I suppose because of constant need to check and execute.

Use the Code well and let me know if anything is not upto your expectation.

Latest Posts

Rooturaj Pattanaik

Technology & Business Consultant with customers across 6 countries. A doting father and loving husband writing about various topics like Technology, Travel, Society, Digital marketing, Investment consulting etc.

MY DICTIONARY PROJECT

I have started a new project called the Indic Dictionary. This will cover popular household words in India and what they are called in various languages. Eventually, I will make this an easy to use app where where people can easily find something like “hing in English” or “Tea Tree Oil in Hindi” or “carrom seeds in Urdu”.
Previous Story

Disable Javascript | Chrome Browser | Enable Javascript

Next Story

Buying Facebook Like or Fans | Be Careful and Ensure this

Latest from Programming

Go toTop

Don't Miss