Re: Loading CSS for AJAX apps.

Alex Duffield
Thu, 15 Jun 2006 23:04:58 -0000

Ya, I have looked at that code in scriptaculous.js but it seems that
that class only uses document.write to put the new links in...

   require: function(libraryName) {
     // inserting via DOM fails in Safari 2.0, so brute force approach
     document.write(''<script type="text/javascript"
src="''+libraryName
+''"> '');
   }

and that doesnt seem to be of any help in dynamicly loading CSS or JS
via an AJAX call.

the "load" function just does a version check and get the path for
loading the rest of the files.



______________________________________________________________________
Alex Duffield . Principal . InControl Solutions . http://
www.incontrolsolutions.com



On 15-Jun-06, at 2:45 PM, Michael Peters wrote:

>
>
> 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