Javascript toastr(jquery)只能显示一次
你能帮我限制一下蟾蜍的外形吗。给定的情况是,当我登录系统时,主屏幕上只会出现一次welcome toastr,并且在我注销之前不会在整个会话中再次出现 这是我的密码Javascript toastr(jquery)只能显示一次,javascript,jquery,Javascript,Jquery,你能帮我限制一下蟾蜍的外形吗。给定的情况是,当我登录系统时,主屏幕上只会出现一次welcome toastr,并且在我注销之前不会在整个会话中再次出现 这是我的密码 setTimeout(function() { toastr.options = { "closeButton": true, "debug": false, "progressBar": true,
setTimeout(function() {
toastr.options = {
"closeButton": true,
"debug": false,
"progressBar": true,
"positionClass": "toast-top-right",
"onclick": null,
"showDuration": "500",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "linear",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
toastr.success("Welcome Admin", "Smartcomp Solutions Inc.");
},1000);
在选项中使用“防止重复”:true,
如果只想显示一次,请尝试以下操作:
toastr.options={
“closeButton”:false,
“调试”:错误,
“newestOnTop”:错误,
“progressBar”:错误,
“positionClass”:“右上角烤面包”,
“防止重复”:正确,
“onclick”:空,
“showDuration”:“300”,
“隐藏”:“1000”,
“超时”:“5000”,
“extendedTimeOut”:“1000”,
“挥杆”:“挥杆”,
“隐藏”:“线性”,
“showMethod”:“fadeIn”,
“隐藏法”:“淡出”
}
var标志=假;
setInterval(函数(){
如果(!标志){
flag=true;//将其存储起来以便以后比较
toastr.success(“欢迎管理员”、“Smartcomp解决方案公司”);
} },1000);代码>
使用一些标志来检查它是否已设置。如果未设置,则保留它。@SuchitKumar我是jquery的新手,你能告诉我怎么做吗?试试张贴的答案……它不起作用,我想要的是只将toastr显示一次作为欢迎通知。如果只想显示一次,请使用setTimeout
而不是setInterval
,另一种方法是在文档中调用toastr而不使用setTimeout
和setInterval
。ready
仍然不起作用,每次我重新加载页面时,它都会运行toastr,然后write是函数的一部分,只有在登录成功时才调用它,在这种情况下,您不需要做任何其他事情。