0
Hello, I’m trying to do a popup, I’ve already set up its structure, I just need to do the validation so it doesn’t keep opening every time I visit the page, I’m trying to use cookie, I don’t know if my code is conflicted in wp or is wrong.
<script>
function setCookie(name,exdays){ //função universal para criar cookie
var expires;
var date;
var value;
date = new Date(); // criando o COOKIE com a data atual
date.setTime(date.getTime()+(exdays*24*60*60*1000));
expires = date.toUTCString();
value = "TESTE123";
document.cookie = name+"="+value+"; expires="+expires+"; path=/";
}
function getCookie(){
var c_name = document.cookie; // listando o nome de todos os cookies
if(c_name!=undefined && c_name.length > 0){ // verificando se o mesmo existe
var posCookie = c_name.indexOf(cookieSeuNome); // checando se existe o cookieSeuNome
if (posCookie >= 0){ //se existir o cookie mostra um alert no browser
document.getElementById('Home_PopBg').style.display = 'none';
}else{}
}
}
</script>