I got a LGPD script that worked perfectly in an html template in VS Code, but I can’t get it to work using Bootstrap Studio.
As I don’t have advanced knowledge in scripting, I’m going to paste all the code and see if any friend finds the problem and helps me with it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LGPD Cookie Consent</title>
<script>
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
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 acceptLGPD() {
setCookie("lgpd_accepted", "true", 365);
document.getElementById("lgpd-banner").style.display = "none";
}
function checkLGPD() {
var lgpd_accepted = getCookie("lgpd_accepted");
if (lgpd_accepted != "") {
document.getElementById("lgpd-banner").style.display = "none";
} else {
document.getElementById("lgpd-banner").style.display = "block";
}
}
</script>
</head>
<body>
<div id="lgpd-banner" style="display:none;">
<p>Este site usa cookies e outras tecnologias semelhantes para melhorar a
sua experiência de navegação. Ao continuar navegando, você concorda com
nossa Política de Privacidade e nossos Termos de Uso.</p>
<button onclick="acceptLGPD()">Aceitar</button>
</div>
<script>
// seu código aqui...
checkLGPD();
</script>
</body>
</html>
Thank you very much, it worked perfectly.
I made some changes to the css to adapt to the mobile version.
Below is the code I used and some screenshots.
<div class="container" id="lgpd-banner">
<strong><span>Lei Geral de Proteção de Dados</span></strong><br><br>
<span>Este site usa cookies para melhor experiência de navegação.</span><br>
<span>Política de Privacidade.</span><br>