In this tutorial we are showing how to show cookie policy popup on website to visitors. This is very simple and clean code for cookie policy popup jut copy below code past into your webpage or inside footer file and save it.
<script> function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; jQuery(".CookiesPolicy").css("display", "none"); } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function checkCookie() { var CookiesPolicyValue = getCookie("CookiesPolicyValue"); if (CookiesPolicyValue != "" && CookiesPolicyValue==1) { jQuery(".CookiesPolicy").css("display", "none"); } else if (CookiesPolicyValue != "" && CookiesPolicyValue==0) { jQuery(".CookiesPolicy").css("display", "none"); } else { jQuery(".CookiesPolicy").css("display", "block"); } } window.onload = checkCookie; </script>
<div class="CookiesPolicy animated zoomIn" style="display:none;"> <div class="left"> This website and its third party subsidiaries use <strong><a href="#">cookies</a></strong>. By continuing to browse, you agree to these cookies being set. </div> <div class="right"> <button class="allow" onclick="setCookie('CookiesPolicyValue', '1', '20')">ALLOW</button> <span class="disallow" onclick="setCookie('CookiesPolicyValue', '0', '1')">NO, THANK YOU</span> </div> </div>
<style> .CookiesPolicy{padding: 10px 50px; position: fixed; bottom: 0px; background: #e0e0e0; z-index: 999; display:none; width: 100%; line-height: 50px;} .CookiesPolicy .left{max-width:77%; float:left; width: auto;} .CookiesPolicy .right{width:23%; float:left; padding-left:10px;} .CookiesPolicy .allow{color: #fff !important; background: #2f5ba2; font-weight: 600; border-radius: 4px; padding: 11px 20px !important; margin: 0px;} .CookiesPolicy .disallow{color: #000000 !important; font-weight: 600; padding: 11px 25px !important; cursor:pointer;} </style>
Tags: cookie consent popup, cookie consent javascript, cookie consent code, cookie consent examples, cookie popup jquery, bootstrap cookie consent, cookie consent message, gdpr cookie consent javascript, cookie policy popup using javascript, cookie policy popup using jquery, cookie policy popup html, how to show cookie policy popup on website, how to create cookie policy popup
My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.