javascript - Can I get text source of link stylesheet? -
i seek css text link element. illustration style
element simplest:
[].map.call(document.stylesheets, function(stylesheet) { var tag = stylesheet.ownernode.tagname.tolowercase(); if (tag == 'style') { homecoming stylesheet.ownernode.textcontent; } else if (tag == 'link') { //is possible receive source here without ajax? } });
is there way link source without loading text?
with document.stylesheets
can interate through loaded stylesheets on page. each 1 list of css rules elements. can obtain csstext
property of these css rules.
based on this post, i've come sample script css rules text loaded on page. hope helps...
http://jsfiddle.net/qmaw7/1/
var cssstyles = ""; //started @ index 1 index 0 browser's user agent stylesheet. for(var i=1; i<document.stylesheets.length; i++) { var style = null; (document.stylesheets[i]) { if (typeof cssrules != "undefined") style = cssrules; else if (typeof rules != "undefined") style = rules; } for(var item in style) { if(style[item].csstext != undefined) cssstyles = (style[item].csstext); } } alert(cssstyles);
javascript html css