Created
September 26, 2018 07:18
-
-
Save dewomser/d4fc4ba97072df1003cb5a61a534d8b6 to your computer and use it in GitHub Desktop.
simple Cookie Banner in Javascript CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
document.cookie = "klicker"; | |
function change() | |
{ | |
document.getElementById("d").style.visibility="hidden"; | |
} | |
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 ""; | |
} | |
var x = getCookie('klicker'); | |
</script> | |
</head> | |
<body> | |
<div id="d" class ="small" style="background-color:lightgrey;"><span style="margin-left: 10px;"> Diese Seite benutzt Cookies Info: <a href="/datenschutz">🍪</a></span> | |
<span style="float:right; margin-right: 10px;"> <a href="#" onclick="document.cookie = 'klicker=Gedruckt; path=/'; change();">ok</a></span> | |
<script type="text/javascript"> | |
if (x == 'Gedruckt'){ | |
change(); | |
} | |
</script> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a a very easy "Banner" Javascript for your homepage. No framework needed. It uses a cookie .
Example: https://wolust.de