Advertisement
Guest User

Untitled

a guest
Jun 18th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. So, erstmal irgendwo die Checkbox einbauen
  2.  
  3. <input type="checkbox" onchange="toggleCookie();" id="radioautoload" /><label>Ich will immer gleich Radio</label>
  4.  
  5. und dann noch diese 2 JS-Funktionen dazu
  6. <script>
  7.     function isRadioCookie() {
  8.         if (document.cookie) {
  9.             var r = document.cookie.search('radio=');
  10.             if (document.cookie.substring(r+6, r+7) == '1') {
  11.                 LoadLautFmRadio();
  12.                 document.getElementById("radioautoload").checked = true;
  13.             }
  14.         }
  15.     }
  16.    
  17.     function toggleCookie() {
  18.         if (document.getElementById("radioautoload").checked) {
  19.             // set Cookie, valid for a year and load radio
  20.             var a = new Date();
  21.             a = new Date(a.getTime() + 1000*60*60*24*365);
  22.             document.cookie = 'radio=1; expires='+a.toGMTString()+';';
  23.             LoadLautFmRadio()
  24.         } else {
  25.             document.cookie = 'radio=0;';
  26.         }
  27.     }
  28. </script>
  29. und die isRadioCookie() musst du dann noch irgendwo nach dem Laden der Seite aufrufen (body onload oder so)
  30.  
  31. (alle Angaben ohne Gewรคhr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement