[Javascript] SAFARI javascript major problem

J. Lester Novros II lester at denhaag.org
Wed Jul 16 11:16:17 CDT 2008


Troy III Ajnej wrote:
> The complete demo code is here

        [snip snip snip]

This worx as expected in Firefox 3.0/Linux, Safari 3.1.2/Apple, Opera 
9.51/Linux, xPloders 6, 7 & 8/WinXP:

------------------------------- code start -------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
            4.01//EN""http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<meta http-equiv="content-type"
        content="text/html; charset=utf-8">

<title>Safari Bug</title>

<link href="test.css"
        rel="stylesheet"
        type="text/css">
</head>

<body>

Not working on Safari!

<script type="text/javascript">
function rulesLength()
{
     var dS = document.styleSheets;
     var theRules = dS[0].rules || dS[0].cssRules;

     alert("selector name: " + theRules[0].selectorText);
     alert("Rules Length: " + theRules.length);
}

     window.onload = rulesLength;
</script>

</body>
</html>

------------------------------- code end -------------------------

with the caveat that xPloders 7 & 8 return rulesLength as 1 more than
the actual number of rules in the style sheet.

Moral of the story: try to avoid running scripts before the page has
loaded completely as much as possible.

l8R lES
-- 
m$' business is scaled and its cost structure is optimized for really,
really big numbers of mindless and fairly undemanding customers.
                                                      Robert X. Cringely
                        http://www.supermarionation.tv



More information about the Javascript mailing list