让浏览器选项卡闪烁通知
出于安全原因,我的网站会在用户闲置 5 分钟后自动注销。我通过 jquery 超时来实现这一点,每当用户执行我认为的“活动”时,超时就会重置。为了确保安全,cookie的超时时间也设置为5分钟,并且我的jquery向服务器执行心跳以确保cookie不会过期。
目前,在大约 4 分钟不活动时,会弹出一个 jquery ui 对话框,警告用户即将超时。用户可以选择保持登录状态、立即注销或不执行任何操作,并在 5 分钟结束时被迫注销。
我的问题是我想让选项卡以不同的背景颜色闪烁,以警告用户在他们不注意的时候发生了一些事情。我只是不确定如何去做这件事。
For security reasons, my website automatically signs users out after 5 minutes of inactivity. I achieve this through jquery timeouts which are reset any time the user does what I consider an "activity". To ensure security, the timeout of the cookie is also set to 5 minutes, and my jquery performs a heartbeat back to the server to ensure the cookie doesn't expire.
Currently, at about 4 minutes of inactivity, a jquery ui dialog pops up, warning the user of their impending timeout. The user can choose to stay signed in, sign out now, or do nothing and they are forced to sign out at the end of the 5 minutes.
My problem is that I want to make the tab flash/blink with a different background color to warn the user that something is going on while they weren't paying attention. I'm just not sure how to go about doing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以更改页面的标题(这也应该更改选项卡中的文本)。
此外,您可以在页面标题和尝试向用户显示的信息之间来回使用
setInterval
来执行此操作。我在 Gmail 上看到了传入聊天通信的这种行为。You can change the title of the page (this should also change the text in the tab).
Additionally you could do this in a
setInterval
back and forth between the page title, and the information you are attempting to show the user. I have seen this behavior on gmail with incoming chat communication.无法更改浏览器选项卡的背景,至少不能在所有选项卡中保持一致。
正如 Josiah 提到的,
setInterval
可用于创建闪烁的页面标题。这个 javascript 利用了它:
可以像这样使用:
请参阅我的以下博客文章以获取更多信息:
http://curtistimson.co.uk/js/create-a-flashing-tab-notification-page-title/
It's not possible to change the background of a browser tab, at least not consistently across all.
As Josiah has mentioned,
setInterval
can be used to create a flashing page title.This javascript makes use of it:
This can be used like:
See my following blog post for more info:
http://curtistimson.co.uk/js/create-a-flashing-tab-notification-page-title/
您还可以添加警报窗口。当用户位于另一个选项卡中时,浏览器具有闪烁选项卡(具有警报)的内置功能。因此,更改文档标题和警报将达到您的目的。注意:在显示警报之前,您需要首先检查选项卡是否处于活动状态。
You can also add an alert window. When user is in another tab, browser has an inbuilt feature of flashing the tabs (having alert). So, changing document title along with an alert will serve your purpose. Note : before showing alert , you need to first check if tab is active.
您可以更改页面标题并将其显示在浏览器选项卡中,但无法更改背景颜色或使其闪烁
you can change the page title and that will show in the browser tab, but you can't change the background color or make it blink