I have a function doing the following using javascript:
- Create link element and set href=cssFile.
- Insert the link element in head tag.
- Create a div element.
- Set the class name using setAttribute
appendChildthe div on body.- Now getting CSS rule value using
document.defaultView.getComputedStyle(divElement, null)[cssRule].
Now getComputedStyle is returning the default values, and if I wait on breakpoint using Firebug before getComputedStyle call, then it returns the CSS rule from the CSS injected.
Regards,
Munim
This is actually what I did.
To ensure a specific CSS file is loaded, I added a style in the end of the CSS file. For example:
Now I have a JavaScript function which will fire the callback specified when the above style is loaded on the page:
And this is how I used the function above:
Here the 1st parameter takes the
optionswhereidis to check against the test style and css property to verify against what loaded from the CSS.