Simple script to check if user have given consent to Iubenda privacy/cookie policy.ย Function will return true if user has given consent, false otherwise.
Semplice script per verificare se l’utente ha dato il consenso alla privacy / cookie policy di Iubenda. La funzione restituirร true se l’utente ha dato il consenso, altrimenti falso.
function iubendaConsentGiven(){ | |
var pairs = document.cookie.split(";"); | |
var cookies = {}; | |
for (var i=0; i<pairs.length; i++){ | |
var pair = pairs[i].split("="); | |
if(pair[0].indexOf('_iub_cs-s') !== –1 || pair[0].indexOf('_iub_cs') !== –1 ) { | |
return true; | |
} | |
} | |
return false; | |
} |
Event style use:
function iubendaConsentGiven(){ var pairs = document.cookie.split(";"); var cookies = {}; for (var i=0; i<pairs.length; i++){ var pair = pairs[i].split("="); if(pair[0].indexOf('_iub_cs-s') !== -1 || pair[0].indexOf('_iub_cs') !== -1 ) { return true; } } return false; } var checkCookie = true; var checkCookieInterval = setInterval(function(){ if(iubendaConsentGiven()){ console.log('ok'); clearInterval(checkCookieInterval); } }, 1000);