当CF7表格成功提交时,永久隐藏Div,直到缓存或cookie被清除



我有这个脚本,当你点击关闭按钮时,它会在5、10、15秒的间隔内弹出一个div

var iteration = 0;
var times = [5,10,15]
var showPopUp = function(time) {
setTimeout(function() { 
jQuery('.pop_timer_box').css('display','flex');
}, time)
}
showPopUp(times[iteration]);
jQuery('body').on('click', '.cclose_pop', function() {
jQuery('.pop_timer_box').hide();
iteration +=1;
if (iteration < <?=$interval_array_count?>) {
showPopUp(times[iteration])
}
});

div中有一个联系人表单7,当表单提交时,下面的代码会隐藏div

document.addEventListener( 'wpcf7mailsent', function( event ) {
if(event.detail.contactFormId == '10917') {
jQuery('.pop_timer_box').hide();
}
}, false ); 

我的问题是如何使它,当我提交一个表单并成功时,弹出表单不会再出现,除非缓存、cookie或本地存储被清除

function setCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
	}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function showNewsletterPopUp(){
	$(window).scroll(function() {
	   if($(window).scrollTop() > 100) {
	    $('.popup').fadeIn(300);	
	   }
	});
	jQuery(function($) {
	    $('.parallax').on('scroll', function() {
	    	if($(".parallax").scrollTop() > 100) {
		    	$('.popup').fadeIn(300);	
			}
	    })
	});
	$('.pop_close').click(function(){
	$('.popup').addClass('hide_this');
});   
}
function checkCookie() {
	
	//console.log('hgghhggh');
var user = getCookie("popup-attribute");
if(typeof user === "undefined" || user == null || user == ''){
	  console.log('HERE');
showNewsletterPopUp();
setCookie("popup-attribute", 'enable', 7);
}
}
checkCookie();

最新更新