dcsimg
www.webdeveloper.com
Results 1 to 9 of 9

Thread: alternate stylesheets

  1. #1
    Join Date
    Aug 2006
    Posts
    1,942

    alternate stylesheets

    I've been playing around with alternate stylesheets, with minor luck. I've implemented the switching mechanism with cookies, as described online at several places, but it seems a bit wacky.

    More specifically, it looks like remnants of the old stylesheet may remain, when the JavaScript loads the new one. Can anyone tell me, do I need to somehow replicate all styles, tags, etc in each of the stylesheets, such that an attribute (e.g. "border:5px") that exists in one, MUST exist in the alternate sheet? If "border" is not in the alternate sheet, I'm thinking it's being set to 5px, even though I might expect the default value of 0px?

    Thanks for any tips. The site I'm fiddling with is at http://www.borzoi.org/indexs.html though I don't really have a specific bug to point at.

    Dave

  2. #2
    Join Date
    Jan 2005
    Location
    Frankfort, KY, USA
    Posts
    6,167
    I'd guess that do need to negate any styles which may carry over to the page, once a new stylesheet is chosen. The stylesheets are cached, just like images; and the page could be pulling from both: the cached "old" version and the new one.

    KDLA

  3. #3
    Join Date
    Aug 2006
    Posts
    1,942
    Thanks, I'm thinking that's what's going on. It makes coding up multiple stylesheets quite annoying, it seems...

    Dave

  4. #4
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    If one stylesheet is disabled via the script none of the style rules in it should affect the document.

    Which browser(s) are you testing in?

    Could you give us a specific example of a style from the default stylesheet that is not overridden via the PDA stylesheet but appears after the stylesheets have been switched?

  5. #5
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    If you embed them using server-side includes I believe you'd sidestep the caching. At any rate, here are some articles at ALA about stylesheet switching.

    http://search.atomz.com/search/?sp-q...p=All&sp-k=All

  6. #6
    Join Date
    Aug 2006
    Posts
    1,942
    Quote Originally Posted by Kravvitz
    If one stylesheet is disabled via the script none of the style rules in it should affect the document.

    Which browser(s) are you testing in?
    Both IE and FF act the same.

    Could you give us a specific example of a style from the default stylesheet that is not overridden via the PDA stylesheet but appears after the stylesheets have been switched?
    I'm still fairly confused on this, but do this and I think you'll get an idea (my apologies for the bulk, I presume I probably should trim this way down to some test site which is much simpler, rather than trying to deal with it as the whole site. Anyway, here's the experiment:

    Go to http://www.borzoi.org/indexs.html
    -presumably it'll come up with the default style sheet, note how the nav bar has hover & visited attributes
    Click on "PDA style" and it should switch the nav bar to blue boxes along the top of the window. This nav bar has no hover or visited attributes, and looks fine on the main page
    Click on the link labeled "Page 2"
    - note the nav bar is all wacky - it now has the hover and visited attributes that come from the default style, but the PDA style seems to still be alive (which it should be, if my code is right).

    That's the symptom, kind of hard to diagnose with all my code in there. The style sheets are at http://www.borzoi.org/site/style.css and PDAstyle.css

    THanks
    Dave

  7. #7
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    The two different pages are using different JavaScript files. I suspect the problem lies there.

  8. #8
    Join Date
    Aug 2006
    Posts
    1,942
    Quote Originally Posted by Kravvitz
    The two different pages are using different JavaScript files. I suspect the problem lies there.
    Holy cow, you're right, and it looks like that was the problem! Thank you, thank you, thank you!

    Dave

  9. #9
    Join Date
    Jul 2005
    Location
    USA
    Posts
    3,910
    You're welcome.

    P.S. Don't forget to validate the XHTML in that second page.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles