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.
Event style use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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); |