Quelltext der Datei: http://www.michaelster.ch/jsTestFolder/cookie.htm

Dateigrösse: 2.33 kb

[Anzeige ohne Zeilennummern]


 1 <!DOCTYPE html>
 2 <html lang="de">
 3   <head>
 4     <meta charset="utf-8">
 5         <title>Analysis Statistics</title>
 6       <!-- https://codepen.io/larrygeams/pen/pdchG -->
 7   <style>
 8     *     { padding: 0; margin: 0; }
 9     @font-face {
10       font-family: 'Lato';
11       font-style: normal;
12       font-weight: 900;
13       src: local('Lato Bold'), local('Lato-Bold'), url(http://themes.googleusercontent.com/static/fonts/lato/v6/wkfQbvfT_02e2IWO3yYueQ.woff) format('woff');
14     }
15     body { margin:2em; background: palevioletred; font-size: 150%; font-family: 'Lato', sans-serif; }
16     h2     { font-variant: small-caps !important; }
17     pre  { display: inline; font-family: monospace; white-space: nowrap; }
18     ol     { list-style-type: square; padding: 15px; display: inline-block; }
19     li     { border: 0px dotted white; padding: 15px 10px; }
20     li:before    { content: "♛ ♜ ♟"; color: yellow; font-size: 200%; }
21     li:after    { content: "♞ ♝ ♚"; color: yellow; font-size: 200%; }
22     li:focus, li:hover { color: white !important; }
23     li:hover:after, li:hover:before { color: black; }
24   </style>
25   
26   
27   <script>
28   
29   Cookie = {
30     get: function (cname) {
31       var name = cname + "=";
32       var ca = document.cookie.split(";");
33       for(var i = 0; i < ca.length; i++) {
34         var c = ca[i];
35         while (c.charAt(0) == ' ') {
36             c = c.substring(1);
37         }
38         if (c.indexOf(name) == 0) {
39             return c.substring(name.length, c.length);
40         }
41       }
42       return null;
43     },
44  
45     set: function (name, value, datum=3600) {
46       var expires = "expires=" + datum;
47       document.cookie = name + "=" + value + ";" + expires;
48     }
49   };
50   // Cookie setzen:
51   Cookie.set("sizeX", screen.availWidth);
52   Cookie.set("session", "yhg65tsg345lo09uzszt087q");
53   Cookie.set("sizeY", screen.availHeight);
54   Cookie.set("sizeiX", window.innerWidth);
55   Cookie.set("sizeiY", window.innerHeight);
56   // Cookie auslesen:
57   v1 = Cookie.get("sizeX");
58   //v2 = Cookie.get("session");
59   v3 = Cookie.get("sizeY");
60   v4 = Cookie.get("sizeiX");
61   v5 = Cookie.get("sizeiY");
62 
63   console.log("screen.availDim: "+v1+" - "+v3+" - window.innerDim: "+v4+" - "+v5);
64 
65   </script>
66  
67 </head>
68 
69 <body>
70 <h2>have a look to the console ...</h2>
71 <pre><ol>
72 <li>
73 F12 (Firefox)
74 </li><li>
75 Ctrl+Shift+I (Chrome)
76 </li>
77 </ol></pre>
78 </body>
79 </html>
80