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
<script type="text/javascript"><!--
function getStyleClass (className)
{
for (var s = 0; s < document.styleSheets.length; s++)
{
if(document.styleSheets
{
for (var r = 0; r < document.styleSheets
{
if (document.styleSheets
{
return document.styleSheets
}
}
}
else if(document.styleSheets
{
for (var r = 0; r < document.styleSheets
{
if (document.styleSheets
return document.styleSheets
}
}
}
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