通知用户JavaScript中是否有新内容 [英] Notify user if there is something new in JavaScript
问题描述
我想用Javascript创建类似的东西,如果我可以使用Extjs来做的话,它会更好:
I would like to create something like this in Javascript, and its better if i can do it with Extjs:
当页面包含新内容时,在按钮上显示一个小的通知图标,然后当用户单击此按钮并打开页面时,该图标消失了.
showing a small notification icon on a button when the page contains something new, then when the user click this button and open the page, the icon gone.
这是简单的HTML5/JavaScript.我每周都会更新网页,希望用户注意到这些更新.
It's simple HTML5/JavaScript. I update the web page weekly and would like users to notice the updates.
推荐答案
这是可能的.您必须在您的计算机中保存 Cookie 用户单击按钮后浏览器.如果设置了Cookie,则可以隐藏通知.
This is possible. You have to save a Cookie in your browser once the user click the button. If the Cookie is set, then you can hide the notification.
这里有个例子:
var myCookie = Ext.util.Cookies.get("YourCookieName");
if(!myCookie){
// show notification
}
然后在按钮上单击:
Ext.util.Cookies.set("YourCookieName", 1);
这篇关于通知用户JavaScript中是否有新内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!