Re: Loading CSS for AJAX apps.

Michael Peters
Thu, 15 Jun 2006 21:45:12 -0000

Sam wrote:
> function LoadCSS(file){
> var head = document.getElementsByTagName(''head'').item(0)
> var linkTag = $(''loadCSS'');
> if(linkTag) head.removeChild(linkTag);
> csslink = document.createElement(''link'');
> csslink.href = file;
> csslink.rel = ''stylesheet'';
> csslink.type = ''text/css'';
> csslink.id = ''loadCSS'';
> head.appendChild(csslink)
> }
>
> Nice.  I''d like to hear of any cross-browser support issues, or
lack
> of.  I can see this being useful in my application if it works.  Has
> anyone tried this in Safari?

Look at scriptaculous.js for a cross browser way of doing this. It''s
specifically doing it with JS files, but I imagine CSS is similar.

--
Michael Peters
Developer
Plus Three, LP