Monday, May 10, 2021
Home Technology Programming Blinking Page Title with Javascript | Flashing HTML page title

Blinking Page Title with Javascript | Flashing HTML page title

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.

1 COMMENT

Comments are closed.

Most Popular

Organic Food and Its Importance for Our Health and Our Planet

Food constitutes one of the pillars of human survival, besides being a source of our energy. Over the years of evolution, food...

List of Organic Vegetables Price in Delhi from Organic Food Suppliers

After facing the pandemic and realizing the need to build strong immunity in our bodies, we today witness a strong push towards...

Top Gift Ideas To Celebrate This Christmas Day With Your Family

Christmas is celebrated every year on the 25th of December. It brings joy and cheers to our life. People celebrate Christmas to...

KBC Question Categories 2020

Kaun Banega Crorepati is one of the most popular t.v game shows in India. The show takes its inspiration from the British...

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”.