Search the web
Sign In
New User? Sign Up
JS-Jive · The premiere Yahoo! Javascript Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Can I use js to include a stylesheet?   Message List  
Reply | Forward Message #21086 of 21091 |
Re: Can I use js to include a stylesheet?

Thanks Hassan. I think I like option number two. So how do I add the class to
the body tag
with js?

--- In JS-Jive@yahoogroups.com, "Hassan Schroeder" <hassan.schroeder@...> wrote:
>
>
> 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@...
>






Fri Jan 2, 2009 5:33 am

tactics2337
Offline Offline
Send Email Send Email

Forward
Message #21086 of 21091 |
Expand Messages Author Sort by Date

This is probably a dumb question, but I'm a js dummie, so forgive me. The idea is I want to have a stylesheet for all users (both with and without js), and...
Dean Hamack
tactics2337
Offline Send Email
Dec 31, 2008
11:48 pm

... 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...
Hassan Schroeder
laughingandj...
Offline Send Email
Jan 1, 2009
6:19 am

Thanks Hassan. I think I like option number two. So how do I add the class to the body tag with js?...
Dean Hamack
tactics2337
Offline Send Email
Jan 2, 2009
5:33 am

... The method you're interested in is `addClassName()` -- google for docs/examples. :-) HTH, -- Hassan Schroeder ------------------------...
Hassan Schroeder
laughingandj...
Offline Send Email
Jan 2, 2009
6:54 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help