Periodic browser title changer

var alertTitle = { TITLETEXT : 'New message!', DEFAULT_TITLE :'Default Title', TIMEOUT : 1000, SPLITTER : 0, TIMER : null, split : function() { if ( 0 == alertTitle.SPLITTER ){ document.title = alertTitle.TITLETEXT; alertTitle.SPLITTER = 1; } else{ document.title = alertTitle.DEFAULT_TITLE; alertTitle.SPLITTER = 0; } alertTitle.TIMER = setTimeout(alertTitle.split, alertTitle.TIMEOUT); }, run : function(){ alertTitle.TIMER = setTimeout(alertTitle.split, alertTitle.TIMEOUT); }, stop : function(){ clearTimeout(alertTitle.TIMER); document.title = alertTitle.DEFAULT_TITLE; } }
Just modify TITLETEXT, DEFAULT_TITLE, TIMEOUT as you want.

To run periodic change of the browser title, call: alertTitle.run(),
to stop blinking call: alertTitle.stop();

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.