4

My coworker wrote a quick mvc chat application so we can chat about work stuff without leaving our desks.

What are some ways to indicate to each other a new message has been posted? My first thought was make the browser title bar flash. Anyone know how?

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80
Rod
  • 14,529
  • 31
  • 118
  • 230

4 Answers4

8

It is not possible to make the browser blink in javascript. A possibility is to set the document title to empty an then write it again with through a period of time with setTimeout()

jorgebg
  • 6,560
  • 1
  • 22
  • 31
  • 3
    +1. This is similar to what many web-based chat applications do. They often simulate a message scrolling on the title bar. – casablanca Aug 12 '10 at 15:36
5

You could play a tone or other audio clip when a new message displays.

The nice thing about an audible cue is that you are able to keep your eyes on your work until you come to a natural break point to answer the message. Visual cues, in my opinion, are more likely to interrupt your work flow.

Obviously you can make the audible cue as pleasant and non-intrusive as your imagination allows.

Community
  • 1
  • 1
Peter Ajtai
  • 56,972
  • 13
  • 121
  • 140
2

This nifty function i got reserved should be handy:

It changes the title of the page to alert the user, and returns the function that will stop the interval(i.e. on a window.onmousemove listener).

function Alert(msg [, ti]) { 
// msg = the message, ti= time interval between title changes(default is 1.5s)
    var intervalId, oldTitle = document.title;
    intervalId = setInterval(function(){
        document.title = document.title == msg ? oldTitle : msg;
    }, ti ? ti : 1500);
    return function() {
    if(oldTitle) {
        clearInterval(intervalId);
        document.title = oldTitle;
    oldTitle = intervalId = null;
    }
    };
}
tcooc
  • 20,629
  • 3
  • 39
  • 57
2

I've written a jQuery plugin for this purpose. See my answer to this question.

Community
  • 1
  • 1
heyman
  • 4,845
  • 3
  • 26
  • 19