I can’t make it work, I’ve tried all possible combinations. All I get is that the first Cookie stops working…
I think I’m doing something wrong that I don’t see.
If I replace the old script with a new one, with a new DIV .name and a new .button , it doesn’t work.
I’m just trying to setup a new one, without the older one, using Travaux for the Cookies.set and anther button.
What’s wrong ??
var Webflow = Webflow || ;
Webflow.push(function() {
// Load cookie library
$.getScript(‘https://cdn.rawgit.com/js-cookie/js-cookie/v2.1.3/src/js.cookie.js’, function() {
// If cookie found (already shown)
if(Cookies.get('travaux') !== undefined) {
// Hide cookie notice (change jQuery selector to match your own)
$('.Travo').remove();
}
// On button click
$('.nuevoboton').click(function() {
// Calculate when you want to display the notice again (change 15 to number of minutes you want)
var expireTime = new Date(new Date().getTime() + 60000 * 1);
// Set this cookie
Cookies.set('travaux', { expires: expireTime });
});
});
});
Why isn’t this correct??
var Webflow = Webflow || ;
Webflow.push(function() {
// Load cookie library
$.getScript(‘https://cdn.rawgit.com/js-cookie/js-cookie/v2.1.2/src/js.cookie.js’, function() {
// If cookie found (already shown)
if(Cookies.get('notice') !== undefined) {
// Hide cookie notice (change jQuery selector to match your own)
$('.cookies_consent_banner').remove();
}
if(Cookies.get('works') !== undefined) {
// Hide cookie notice (change jQuery selector to match your own)
$('.travo').remove();
}
// On button click
$('.agree_button').click(function() {
// Calculate when you want to display the notice again (change 15 to number of minutes you want)
var expireTime = new Date(new Date().getTime() + 60000 * 1);
// Set this cookie
Cookies.set('notice', 'shown', { expires: expireTime });
// On button click
$('.nuevoboton').click(function() {
// Calculate when you want to display the notice again (change 15 to number of minutes you want)
var expireTime = new Date(new Date().getTime() + 60000 * 1);
// Set this cookie
Cookies.set('works', 'shown', { expires: expireTime });
});
});
});
I’ve solved it by pasting the second script in the head section of the specific page in which the new DIV was mean to appear:
For in the case this helps someone else in the future, here is the final script for the second cookie:
var Webflow = Webflow || ;
Webflow.push(function() {
// Load cookie library
$.getScript(‘https://cdn.rawgit.com/js-cookie/js-cookie/v2.1.2/src/js.cookie.js’, function() {
// If cookie found (already shown)
if(Cookies.get('testing') !== undefined) {
// Hide cookie notice (change jQuery selector to match your own)
$('.travo').remove();
}
// On button click
$('.nuevoboton').click(function() {
// Calculate when you want to display the notice again (change 15 to number of minutes you want)
var expireTime = new Date(new Date().getTime() + 60000 * 1);
// Set this cookie
Cookies.set('testing', 'shown',{ expires: expireTime });
});
});
});
What I miss in situations like this, is a proper video with instructions. A code we can use and a short explanation of how to adjust the code after our needs.
I think the Webflow crew would save a lot of time if things like this was just explained really well ONE time. 99% of all websites need a cookie message.
I don’t understand a thing of what is being said in this thread. Would love a walkthrough. <3