Accueil > JavaScript > cssStylesheetManager.js # Javascript library that manage alternate CSS stylesheet.

cssStylesheetManager.js # Javascript library that manage alternate CSS stylesheet.

28/01/2009
  1. /** 
  2.  * Javascript library that manage alternate CSS stylesheet. 
  3.  * FileName: cssstylesheetmanager.js 
  4.  * Date:     15/11/2006 
  5.  * Author:   Gabriel DROMARD 
  6.  * Require:  Prototype.js 
  7.  */  
  8.   
  9. /** 
  10.  * Set current CSS Stylesheet. 
  11.  */  
  12. Event.observe(window, 'load', setCurrentCSSStylesheet, false);  
  13.   
  14. /** 
  15.  * Set active CSS Stylesheet. 
  16.  * @param title The CSS stylesheet to activate 
  17.  */  
  18. function setActiveCSSStylesheet(title) {  
  19.     var i, a, main;  
  20.     for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {  
  21.         if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {  
  22.             a.disabled = true;  
  23.             if(a.getAttribute("title") == title) a.disabled = false;  
  24.         }  
  25.     }  
  26.     setCookie('PingusActiveStyleSheet', title);  
  27. }  
  28.   
  29. /** 
  30.  * Active an already set CSS Stylesheet. 
  31.  * (This function use cookies) 
  32.  */  
  33. function setCurrentCSSStylesheet() {  
  34.     var current = getCookie('PingusActiveStyleSheet');  
  35.     if(current != undefined && current != null)  
  36.         setActiveCSSStylesheet(current);  
  37. }  

JavaScript

Les commentaires sont fermés.