Finding a suitable jQuery script to help your website comply with the cookie law can be time consuming and complicated.
Cookie Law is different. Simply include the jQuery & CSS files in your website <head>
and invoke it with the following jQuery snippet - $.cookieLaw();
.
Clear Cookie View Non-Implied Version
If you're interested in customizing Cookie Law then you can use the following options to help you along.
Option Name | Type | Default | Description |
---|---|---|---|
impliedConsent | Boolean | true | States whether consent should be implied when the user views the notification or when they click the "I Accept" button. |
title | String | 'Our Cookie Policy' | The title of the notification window. |
shortMessage | String | 'This website uses cookies to improve your experience. By continuing to use this website you are giving consent to cookies being used.' | The main message that is shown within the notification window. |
longMessage | String | 'Cookies are small text files held on your computer. They allow us to give you the best browsing experience possible and mean we can understand how you use our site.' | The message shown to the user after clicking the "More Info" button. |
onAccepted | Callback | - | If consent is implied this callback is fired after the notification window is loaded. If consent is not implied this callback is fired when the user clicks the "I Accept" button. After that is then fired each time the user visits your website. |
Installation And Setup Guide
<link rel="stylesheet" href="https://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
<link rel="stylesheet" href="csscookies/notify.css" />
<link rel="stylesheet" href="csscookies/cookie-law.css" />
4. <!-- Place Below code before close html at body section ! -->
<script src="jscookies/jquery-1.7.1.min.js"></script>
<script src="jscookies/jquery-notify.min.js"></script>
<script src="jscookies/cookie-law.min.js"></script>
<script>
$(function(){
$.cookieLaw({
onAccepted: function(){
$('#cookieStatus').val('Accepted!');
}
});
$('#viewNonImplied').click(function(){
$('#cookieStatus').val('Not Accepted');
var date = new Date();
date.setTime(date.getTime()-1);
document.cookie = "euCookieLaw=; expires="+date.toGMTString()+"; path=/";
$('#notification_area li').remove();
$.cookieLaw({
impliedConsent: false,
onAccepted: function(){
$('#cookieStatus').val('Accepted!');
}
});
})
$('#clearCookie').click(function(){
$('#cookieStatus').val('Not Accepted');
var date = new Date();
date.setTime(date.getTime()-1);
document.cookie = "euCookieLaw=; expires="+date.toGMTString()+"; path=/";
})
})
</script>