-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
75 lines (71 loc) · 2.14 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!doctype html>
<html>
<head>
<style>
body {
margin: 0;
padding: 0;
}
h1 {
background: #800000;
font-size: 50px;
margin: 0;
padding: 20px 50px;
color: #FFF;
font-family: "Times New Roman";
}
p {
padding: 0 20px;
font-family: verdana;
font-size: 16px;
line-height: 150%;
}
pre.code {
margin: 0 100px;
background: #DEDEDE;
font-family: courier;
font-size: 12px;
padding: 5px;
}
span.code {
background: #DEDEDE;
font-size: 12px;
font-family: courier;
}
</style>
<meta charset="utf-8">
<title>Test Cookie Script</title>
<script src='./src/cprompt.min.js'></script>
</head>
<body>
<a href="http://github.com/michaelw90/cPrompt"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/camo.github.com/30f550e0d38ceb6ef5b81500c64d970b7fb0f028/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub"></a>
<h1>cPrompt</h1>
<p>
The idea is simple, a piece of JavaScript that can be thrown into any page, that can be used to automatically show the above banner to new visitors to check that you are allowed to store cookies.<br />
The ability is then in place so that you can simply check that this cookie is set by calling the following line which will return a boolean depending on whether you're able to set cookies or not:
</p>
<pre class='code'>cPrompt.checkCookie()</pre>
<p>
Using it around Google Analytics is as simple as doing this:
<pre class='code'>
if(cPrompt.checkCookie()){
/**
Google Analytics Code Here
**/
}
</pre>
</p>
<p>
<strong>Note:</strong> This will display on every page load for the user, and doesn't make use of the clause within the law that allows you to assume acceptance if the user ignores the notice.
</p>
<p>
<script>
if(cPrompt.checkCookie()){
document.write('You can see this as you have accepted the cookie saving feature!');
}else{
document.write('You can see this as you have <strong>not</strong> yet accepted the cookie saving feature');
}
</script>
<p>
</body>
</html>