Friday, September 30, 2022
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

Top 10 Coding Competitions for Kids: Junior Coding Championships worldwide

If your child has been into coding and app development recently and you wish to show off their coding skills then enrol...

Turn on Less Secure Apps in Google Workspace Gmail accounts

Sometimes a developer needs to send emails from Gmail or Google Workspace email account or mail server from their website or app....

Construction Financing: Everything You Need to Know

Thinking about building a new home? Construction financing can help. In this article, we will help you figure out...

Set Shipping Rules on Wix

We understand that working on wix control panel can be a little overwhelming to beginners. Despite having 12 years of experience in...

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