Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Imported Stylesheets

Status
Not open for further replies.

bacooper81

Programmer
Joined
Dec 5, 2005
Messages
2
Location
US
Hi. I'm trying to access an imported stylesheet in using the msdn command "document.styleSheets[0].imports". It works fin in IE, but when I use Firefox I'm getting an "Error: document.styleSheets[0].imports has no properties". Does anyone know how I can get this to work with Firefox?

Thanks,
Brian
 
I did some googling and found the following code:
Code:
function getcss( selector, property ) {
var i, r, s=document.styleSheets && document.styleSheets[0]; if(s) {
r = s.rules ? s.rules : s.cssRules; if(r) {
i = r.length; while (i--) {
if(r[i].selectorText.toLowerCase() === selector.toLowerCase()) {
return ( r[i].style[property] );
}
}
}
}
return null;
}

alert( getcss( '.myclass', 'fontSize' ) );
You can see the full text here:
Hope this helps.
HardingD
 
Thanks, but this still doesn't seem to look at any imported style sheets. I was thinking there should be a simmilar function to msdn's styleSheet.imports[index]. Maybe???
 
What exactly is it that you are trying to do with imported style sheets? Maybe there is another way to achieve this - but it would be hard to say, as you've not really given much to go on.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top