Thanks for the tip Sergiu. I will give this a try and hope it works out.

Message: 9
Date: Tue, 16 Mar 2010 19:00:55 +0100
From: Sergiu Dumitriu <ser...@xwiki.com>
Subject: Re: [xwiki-users] Call CSS from inside a JS file
To: XWiki Users <users@xwiki.org>
Message-ID: <4b9fc757.1080...@xwiki.com>
Content-Type: text/plain; charset=UTF-8; format=flowed

On 03/16/2010 06:28 PM, Dilipkumar Jadhav wrote:
> Hi Sergiu,
> I phrased my question incorrectly. I am required to load CSS files
> conditionally using JS. There is a GPL licensed Nifty Cube library
> that is used for creating round corner effects which I was trying to
> import into my wiki. Here is the code snippet where I am stuck:
>
>
----------------------------------------------------------------------------
-----------------------------------
> var oldonload=window.onload;
> if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
> if(typeof(oldonload)=='function')
>      window.onload=function(){oldonload();AddCss();NiftyLoad()};
> else window.onload=function(){AddCss();NiftyLoad()};
>
> function AddCss(){
> niftyCss=true;
> var l=CreateEl("link");
> l.setAttribute("type","text/css");
> l.setAttribute("rel","stylesheet");

Set the parse option of the JSX object to Yes, then replace the next 
line with:

l.setAttribute("href", "$doc.getURL('ssx')");

> l.setAttribute("href","niftyCorners.css");
> l.setAttribute("media","screen");
> document.getElementsByTagName("head")[0].appendChild(l);
> }


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/


_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to