Jos*_*osh 21 browser jquery notifications tabs
出于安全原因,我的网站会在闲置5分钟后自动将用户注销.我通过jquery超时实现这一点,当用户执行我认为是"活动"的任何时候都会重置.为了确保安全性,cookie的超时也设置为5分钟,我的jquery会向服务器发送心跳以确保cookie不会过期.
目前,在大约4分钟不活动时,会弹出一个jquery ui对话框,警告用户即将发生超时.用户可以选择保持登录状态,立即退出或不执行任何操作,并且在5分钟结束时他们被迫退出.
我的问题是我想使用不同的背景颜色使选项卡闪烁/闪烁,以警告用户在他们没有注意时发生了什么事情.我只是不确定如何去做这件事.
Jos*_*ell 24
您可以更改页面标题(这也应该更改选项卡中的文本).
document.title = 'New title';
Run Code Online (Sandbox Code Playgroud)
此外,您可以setInterval在页面标题和您尝试向用户显示的信息之间来回执行此操作.我在gmail上看到了这种与传入聊天通信的行为.
Cur*_*urt 16
无法更改浏览器选项卡的背景,至少在所有选项卡中不一致.
正如Josiah所提到的,setInterval可以用来创建一个闪烁的页面标题.
这个javascript使用它:
var PageTitleNotification = {
Vars:{
OriginalTitle: document.title,
Interval: null
},
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;
}
}
Run Code Online (Sandbox Code Playgroud)
这可以像:
PageTitleNotification.On("User logged out!");
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅我的以下博文:
http://curtistimson.co.uk/js/create-a-flashing-tab-notification-page-title/
| 归档时间: |
|
| 查看次数: |
31311 次 |
| 最近记录: |