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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

css targeting with javascript

Status
Not open for further replies.

incarnate

Technical User
Mar 16, 2007
1
US
I am currently using the following code:
<script type="text/javascript"><!--

function getStyleClass (className)
{
for (var s = 0; s < document.styleSheets.length; s++)
{
if(document.styleSheets.rules)
{
for (var r = 0; r < document.styleSheets.rules.length; r++)
{
if (document.styleSheets.rules[r].selectorText == '.' + className)
{
return document.styleSheets.rules[r];
}
}
}
else if(document.styleSheets.cssRules)
{
for (var r = 0; r < document.styleSheets.cssRules.length; r++)
{
if (document.styleSheets.cssRules[r].selectorText == '.' + className)
return document.styleSheets.cssRules[r];
}
}
}
return null;
}

// --></SCRIPT>

It is just a script to get the name of a style sheet so that it can be targeted. I'm wondering if there is something wrong with the code because it works on many machines, but on some other machines (including the one of the person I am designing the site for) the script does not work. If you look at the source code on those machines it had an error script in place of my script. Any advice?
thanks
 
it had an error script in place of my script

Can you define a bit more what you mean by that? Was your script not in place at all, but replaced with an entirely different script?

If so, chances are they have some sort of firewall or security software (such as Norton Security Suite, etc) installed that is blocking your script from loading.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

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

Part and Inventory Search

Sponsor

Back
Top