I have checked it on 4.3.1 and 4.3.2 and it also doesn´t work.
But for Cookie Message its not the best, because there is no Opt in or Opt out option. You need that option for example when you use maps and analytic tools. Other Modal Codes just work ( Snippet Site Pealco )
Ok, and what I have to do that the code is working? The cookie bric is ok but I can’t chance the fonts and other design elements. I would like to get my own modal for cookies.
This should work for you. Basically the same, just the calling the modal is different in Bootstrap 5.
<script>
document.addEventListener("DOMContentLoaded", function() {
if (document.cookie.indexOf('visited=true') == -1){
var cookieModal = new bootstrap.Modal(document.getElementById('modal-cookie'));
cookieModal.show();
var year = 1000*60*60*24*365;
var expires = new Date((new Date()).valueOf() + year);
document.cookie = "visited=true;expires=" + expires.toUTCString();
}
});
</script>