I’d like to get the stylesheet rules (or css textContent) from css files linked in the head of my page. document.styleSheets seems to work in all major browsers, but styleSheets[0].cssRules of course fails in IE<9 . What is the proper approach for this solution ? Loading files with AJAX ? But then I’m just limited to styles from the same domain.
I’d like to get the stylesheet rules (or css textContent) from css files linked
Share
For IE you can use
rulesproperty ofstyleSheetsobjects.So the universal solution can be:
DEMO: http://jsfiddle.net/tqgNb/