Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple EU Cookie Law Banner JavaScript
@Showcase-Joz

This comment has been minimized.

Copy link

commented Jan 29, 2014

thanks a lot, smashing help guys ;)

@YoannLeGoff

This comment has been minimized.

Copy link

commented Dec 16, 2014

Hi,
I've created a little fork of this one, as I think it's more user friendly to create the cookie when the user click on "close" instead of pushing the cookie once the text is displayed...

If you implement that in next version let me know so i'll trash that fork.

Cheers.

@MPMachado

This comment has been minimized.

Copy link

commented Apr 20, 2018

Thanks for sharing. I implemented this solution, but I noticed that when I refresh, the banner is removed. It's a normal behaviour?

@maxmiko

This comment has been minimized.

Copy link

commented May 23, 2018

Anybody could help, how to update this code? Because it is disappear on refresh?

@dogseven

This comment has been minimized.

Copy link

commented May 27, 2018

It disappears, as it should, because it is assumed that you have agreed to it. That's what's in the text. It will re-appear after 14 days. Visitors won't want to see it every time they visit the page.

To see it again, delete the domain cookies for this site.

@m4con

This comment has been minimized.

Copy link

commented Jul 24, 2018

Hi,
what should the following code do?
if(window.dropCookie){ document.cookie = name+"="+value+expires+"; path=/"; }
Can't find a dropCookie property on the window object.

Best regards.

@timgerhard

This comment has been minimized.

Copy link

commented Jul 18, 2019

You can use this css:

/* [COOKIE BANNER] */
#cookie-law {
    position: fixed;
    z-index: 99999;
    background: white;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
    text-align: center;
    padding: 30px 0;
    right: 0;
    bottom: 0;
    left: 0;
}

#cookie-law p {
    margin: 0;
}

.close-cookie-banner span {
    position: absolute;
    top: 0;
    color: black;
    font-size: 25px;
}
/* [/COOKIE BANNER] */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.