JavaScript

Title - a javascript snippet to control the document title


22nd of August 2011

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



Comment

 

Commenting is currently disabled in Mobile version