mRt
mRt

Reputation: 1223

CRM, Javascript and Dynamic CSS

I need to include a link to a css file, but, the name changes. The problem is, I am working with MSCRM 2011, and I am integrating a custom pop up window, that I need to have the "CRM style"

The link looks like this:

<LINK rel=stylesheet type=text/css href="/MyOrgtest/_common/styles/fonts.css.aspx?lcid=1033&amp;ver=-900509389">

The thing is, when I do it in a test environment (organization "MyOrgTest") the css link names includes the organization.

So, I need to, somehow, dynamically change this link, with something like a wildcard... I don't know, so I do not have to change the link manually.

Is this possible???

Upvotes: 2

Views: 4453

Answers (1)

David Spence
David Spence

Reputation: 8079

If you open your solution (Settings > Solutions > Open your solution) and select "Web Resources" you should be able to add an html page like you have done with your css file. It will have a url just like your css file:

<Microsoft CRM URL>/WebResources/<name of Web resource>

You can then reference your css file by a relative path like:

<link rel="stylesheet" type="text/css" href="/styles/fonts.css" />

An un-necessary alternative would be to dynamically generate the url of the css via javascript, using the context to get the server url:

var context = GetGlobalContext();
var serverUrl = context.getServerUrl();
var cssPath = serverUrl + "/WebResources/styles/fonts.css";

Once you had this you could check questions like this one to add the css file via javascript.

Upvotes: 3

Related Questions