日期:2014-05-16 浏览次数:20541 次
转自:http://pushingtheweb.com/2010/10/reaching-out-of-the-browser-sandbox-using-jquery-title-alert/
?
Most websites that we develop at ESN are social websites with real-time features. Features that are in real-time on these websites might be contact lists with chat features, counter-strike game lobbies, social activity feeds, and so on. Having these features in real-time really enhances the over all functionality of the websites, especially together with some ways of making users aware of the updates, like animations and toasters.
These websites – as well as many others on the net like Facebook, Twitter, Gmail, Last.fm (the list goes on forever) – are more and more taking the role that was previously hold by normal applications like Thunderbird, Emacs, Skype, etc. When using such web application, it’s normal user behavior to multitask between different web pages and programs, just like one would do using a normal application, like Skype. However, OS level programs have ways to alert the user when certain events occur (i.e. someone sends you a message), that web application is some what lacking, because they live in the browser sandbox. This is a problem, because the usefulness of having a user-to-user chat in real-time, decreases a great deal, if one has to manually go and check for new messages while having another website, or another program, focused. One solution to this is to show notification messages in the browser’s title bar.
That’s why I wrote jQuery Title Alert about a year ago. It’s a small jQuery plugin for displaying a flashing notification message in the browser’s title bar. It supports setting different intervals and timings, that defines the appearance of the notification, as well as options for stopping the title notification when the browser get focus.
Hopefully someone will find the plugin very useful as a complement to a website that uses a real-time service like BeaconPush .
Here is an example on how to use it:
(See the documentation
for all available options)
$.titleAlert("New chat message!", { stopOnFocus:true, duration:60000, interval:500 });
Go ahead and grab it in my original blog post , or at the project GitHub page . And feel free to fork it as much as you want!