Title - a javascript snippet to control the document title

22 August 2011   0 comments   Javascript

Powered by Fusion×

This is a piece of Javascript code I use on Kwissle to make the document title change temporarily. Other people might find it useful too.

Code looks like this:

var Title = (function() {
 var current_title = document.title
   , timer;

 return {
    showTemporarily: function (msg, msec) {
      msec = typeof(msec) !== 'undefined' ? msec : 3000;
      if (msec < 100) msec *= 1000;
      if (timer) {
        clearTimeout(timer);
      }
      document.title = msg;
      timer = setTimeout(function() {
        document.title = current_title;
      }, msec);
    }
 }
})();

Demo here

Comments

Thank you for posting a comment

Your email will never ever be published


Related posts

Previous:
EmailInput HTML5 friendly for Django 02 August 2011
Next:
Reciprocal lesson about gender perspectives 02 September 2011
Related:
TornadoGists.org - launched and ready! 06 April 2011
The importance of the TITLE attribute 23 April 2008