[Javascript] SAFARI javascript major problem
Roger Roelofs
rer at datacompusa.com
Thu Jul 17 12:41:47 CDT 2008
Troy,
On Jul 16, 2008, at 5:54 PM, Troy III Ajnej wrote:
> Hello, Novros.
>
> You are replying to a non existing question||problem same time.I
> already posted the "only how", that shall work in Safari.
> Exactly the one you've just posted...
Try this in Safari, ff and ie. I think you will find that Safari (and
perhaps Opera, untested) is allowing the javascript to continue to
execute at the same time the css is loading and ff and ie are causing
the javascript to stop until all the stylesheets are loaded.
---------------- code -----------
<!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">
<script type="text/javascript">
function rulesLength() {
alert("in rulesLength");
var dS = document.styleSheets;
var theRules = dS[0].rules || dS[0].cssRules;
alert("selector name: " + theRules[0].selectorText);
alert("Rules Length: " + theRules.length);
}
try {
rulesLength()
}
catch(err) {
}
window.onload = rulesLength;
</script>
</head>
<body>
<h1>Page Loaded</h1>
</body>
</html>
---------------- code -----------
In short, if you wait until the onload event, all the major browsers
play nice. If you try before onload, different browsers behave
differently.
Roger
--
Roger Roelofs
Datacomp Appraisal Services
3215 Eaglecrest, NE
Grand Rapids, MI 49525
More information about the Javascript
mailing list