/ Published in: JavaScript
changed to detect sring sheet first, then to try object extension.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var CSSLoader = { addStylesheets: function(sheets, elm){ var l = sheets.length; if( !l ) return; elm = $(elm) || $$('head')[0]; if( !elm ) return; for( var i=0; i<l; i++){ var sheet = sheets[i]; var info = { rel: 'stylesheet', type: 'text/css', media: 'screen' } if( Object.isString(sheet)){ Object.extend(info, {href: sheet}); }else{ try{ Object.extend(info, sheet); }catch(e){ continue; } } var temp = new Element('link', info); elm.insert(temp); } } };