Welcome to WebmasterWorld Guest from 54.224.230.51

Forum Moderators: open

Message Too Old, No Replies

Is document.styleSheets broken in Safari?

     
7:22 pm on Mar 20, 2008 (gmt 0)

New User

5+ Year Member

joined:Nov 6, 2007
posts: 22
votes: 0


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<script type="text/javascript">
alert(document.styleSheets.length);
</script>
</body>

Is this supposed to work in Safari?
It's returning 0... There's a style sheet there! No, style.css isn't 404ing...

Tried on Safari/Win, Safari/Mac, and Safari/iPod Touch

10:06 pm on Mar 20, 2008 (gmt 0)

Full Member

5+ Year Member

joined:Mar 4, 2008
posts: 210
votes: 0


javascript:alert(document.styleSheets.length);
in the location bar of Safari/Win 3.0.2 works for me (returns '2' for a particular page that was handy).

Try running your javascript via <body onload='yourScriptHere()'>.

[edited by: MarkFilipak at 10:09 pm (utc) on Mar. 20, 2008]