码迷,mamicode.com
首页 > Web开发 > 详细

jquery 通知页面变化

时间:2015-10-09 13:32:05      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

var PageTitleNotification = {
    Vars: {
        OriginalTitle: document.title,
        Interval: null,
        IsNotificationEnabled: false
    },
    On: function (notification, intervalSpeed) {
        var _this = this;
        _this.Vars.Interval = setInterval(function () {
            document.title = (_this.Vars.OriginalTitle == document.title)
                                ? notification
                                : _this.Vars.OriginalTitle;
        }, (intervalSpeed) ? intervalSpeed : 1000);
    },
    Off: function () {
        clearInterval(this.Vars.Interval);
        document.title = this.Vars.OriginalTitle;
    }
}
$(window).focus(function () {
     PageTitleNotification.IsNotificationEnabled = false;
     PageTitleNotification.Off();
});

$(window).blur(function () {
     PageTitleNotification.IsNotificationEnabled = true;
});
if (PageTitleNotification.IsNotificationEnabled)
    PageTitleNotification.On("New Chat Message!");

 

jquery 通知页面变化

标签:

原文地址:http://www.cnblogs.com/JasonLiao/p/JqueryNotifyPageActive.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!