Solutions for Cookie Consent problems
Here you can find solutions to common problems. Report issues on Cookie Consent GitHub page.
1. How to get top pushdown to work with a fixed navigation bar?
You’ll need to add top margin to your navigation bar on popup open and remove it on close.
window.cookieconsent.initialise({
palette: {popup:{background:"#000"},button:{background:"#f1d600"}},
position: "top",
static: true,
onPopupOpen : function () {
pushDown(this.element.clientHeight);
},
onPopupClose : function () {
pushDown(0);
}
});
function pushDown(height) {
var navbar = document.getElementsByClassName(" NAVBAR CLASS ")[0];
navbar.style.transition = 'all 1s';
navbar.style.marginTop = height+'px';
}
2. Javascript TypeError
null is not an object (evaluating 's.firstChild')
This error message usually means that the body of your website is loaded dynamically and after Cookie Consent.
Try moving the scripts to the footer, just before the closing the body tag.
3. How to use Cookie Consent in my own language or on a multilingual site?
Cookie Consent is only available in English. However, you can configure every line of text on cookie consent window. This can be done dynamically on multilingual sites using your own translation files/scripts.
Example:window.cookieconsent.initialise({
palette: {
popup:{
background:"#000"
},
button:{
background:"#f1d600"
}
},
content: {
message: "//MESSAGE_IN_CURRENT_LANG",
dismiss: "//DISMISS_BUTTON_IN_CURRENT_LANG"
}
});