cherryprodesign

Live CSS váltó

Mar 28th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. $(document).ready(function(){
  3.  var css = getCookie("cssurl");
  4.     if (css != "") {
  5.         changeStyle(css);
  6.     }  
  7. });
  8. function getCookie(cname) {
  9.     var name = cname + "=";
  10.     var ca = document.cookie.split(';');
  11.     for(var i=0; i<ca.length; i++) {
  12.         var c = ca[i];
  13.         while (c.charAt(0)==' ') c = c.substring(1);
  14.         if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
  15.     }
  16.     return "";
  17. }
  18. function changeStyle(url){
  19.     if( $('link.style').length > -1 ){
  20.         $('link.style').remove();
  21.     }
  22. /*ha oldal modulban használsz alap css-t, az ez alatti részt kommenteld ki, és a modul id-t cseréld ki*/
  23.  
  24. /*  if($('table[module_id="36921729"]').length > -1){
  25.         $('table[module_id="36921729"]').empty();
  26.     } */
  27.  
  28. // külső css fájl esetén a css fájlod nevét add meg itt
  29.     if($('link[href="http://nikkiiworld.flaunt.nu/gp_css/css1.css"]').length > -1){
  30.         $('link[href="http://nikkiiworld.flaunt.nu/gp_css/css1.css"]').remove();
  31.     }
  32.     var css = document.createElement('link');
  33.         css.setAttribute('rel', 'stylesheet');
  34.         css.setAttribute('class', 'style');
  35.         css.setAttribute('href', url);
  36.         document.head.appendChild(css);
  37.  
  38.     document.cookie="cssurl="+url+";path=/";
  39. }
  40. </script>
Add Comment
Please, Sign In to add comment