cssRules are null in Chrome
This is turning up null all of a sudden. I'm running version 5.0.375.70
shows null in chrome with a very simple test page and single css file with just one rule, but turns up as an CSSRuleList for FF Safari, Opera etc...
document.styleSheets.rules is also null in my Chrome browser. How do i get the css rules in chrome? I think this actually used to work in my older versions of chrome but now I'm second guessing myself.
Have you tried Safari? Both browsers use Webkit as their engine so if it works or does not work on one it should happen on the other one too.
According to Quirksmode, Safari supports both cssRules and rules.
right, but this is my code, maybe there is a error.
<link rel='stylesheet' type='text/css' href='test.css'>
yes, working safari, not chrome - strange i know.
perhaps a file path error. I just have test.css in the same dir as my htm test file posted above.
Still no problem in Chrome
odd, when i uploaded it to my webserver it worked. my server is unix, my pc is windows, so i tried changing it from href='test.css' to href='/test.css' and that fixed it locally
problem solved... i = nub.
Its a good bet that Ims is using the file: protocol to test his code.
I usually work on a server, and have had no troubles with any of the Chromes and their styleSheets methods.
When I opened a page from the file system Chrome was the only browser that would not expose some of the styleSheets rule sets, although it could find every styleSheet loaded.
It seems to be a file permissions weirdness, though not even Safari 5 shares it.
Test your code on a local server with http: instead of the file system. It's the only way to use IE without getting a migraine, but all the browsers are really built for http.
Last edited by mrhoo; 06-12-2010 at 10:36 PM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)