On Wed, Dec 31, 2008 at 3:48 PM, Dean Hamack <lists@...> wrote:
> The idea is I want to have a stylesheet for all users (both with and without
> js), and override
> some of those styles if the user has js. I tried the following, but it
> doesn't seem to work:
> Can you only use document.write in the body? And if so, is there another way
> to accomplish this?
document.write is (IMO) clumsy and ugly, and doesn't work in a true
XHTML page. Forget you ever heard of it :-)
Alternatives:
1) directly manipulate the style rules -- google "DOM stylesheet" for
more info and examples; probably won't scale well if you have a
lot of rules. Also, there are some browser compatibility issues --
surprise!
2) put all your rules in one stylesheet; make the "with JS" rules depend
on the cascade, e.g.
h1 { color: red; } /* no JS style */
.js h1 { color: green; } /* with JS style */
and add the class "js" to the body tag via JavaScript.
FWIW!
--
Hassan Schroeder ------------------------ hassan.schroeder@...