Milan Lund logo

Hi, I am Milan Lund!Full Stack Web Developer

I specialise in building websites and web applications with Kontent.ai and Kentico platforms.

  • Front-end

Simple cookie bar

EU cookie legislation requires website owners to inform visitors about the use of cookies. In this article, I will provide you with a simple solution of an informative cookie bar.

What it does

When a page gets loaded, a message shows up. If the visitor closes the message, a localStorage flag gets set, and the message won´t display any more. See the example.

The code

The solution consists of 2 parts:

  • logic based on Javascript and
  • styling.


Both parts need to be implemented in the website to make it work. For javascript, you can find jQuery and vanilla implementations below.
For styling, you can choose from CSS or LESS implementations.

Please, note that the javascript code relies on the existence of the ".footer" element. You can, of course, change it according to your taste.

jQuery

Loading...

Vanilla javascript

Loading...

CSS

Loading...

LESS

Loading...