gpt4 book ai didi

javascript - 更新时向用户显示模式

转载 作者:行者123 更新时间:2023-12-03 04:41:30 25 4
gpt4 key购买 nike

我已经制作了这个模式,它仅在第一次访问网站时显示

$(document).ready(function(){
setTimeout(function(){
if(!Cookies.get('modalShown')) {
$("#myModal").modal('show');
Cookies.set('modalShown', true);
} else {
alert('You already saw the modal')
}
},1000);
});

在模式中,它显示了应用程序添加的新功能的内容。所以我的目标是每次更新模态内容时向用户显示模态。我怎样才能做到这一点?

最佳答案

您可以在 cookie 值中使用版本控制:

var currentRelease = "1.0.1",
currCookie = Cookies.get('modalShown')

setTimeout(function(){
if(!currCookie || currCookie != currentRelease) {
$("#myModal").modal('show');
Cookies.set('modalShown', currentrelease);
} else {
alert('You already saw the modal')
}
},1000);

请注意,此方法会强制您更新“currentRelease”的值您还可以将模态的文本内容加密为 md5 并在 cookie 中使用该值,因此每当模态值更改时,md5 也会更改

关于javascript - 更新时向用户显示模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43069622/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com