Results 1 to 5 of 5

Thread: Style Sheet Switcher- 30 max Css's for IE?

  1. #1
    Join Date
    May 2012
    Location
    Wisconsin
    Posts
    9
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Style Sheet Switcher- 30 max Css's for IE?

    1) Script Title:

    Style Sheet Switcher (v1.1)

    2) Script URL (on DD):

    http://www.dynamicdrive.com/dynamici...etswitcher.htm

    3) Describe problem:

    I am using styleswitch.js as a test bed to show various different background colors (35 different style sheets including the default) for a webpage. In IE, there seems to be a limit on how many various css's I can use. (stops working after the 30th .css).

    In Firefox it works great for all of them.

    So is there something I can add to allow my full list to work on IE?


    Thanks for any help.
    Douglas

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,024
    Thanks
    44
    Thanked 3,209 Times in 3,171 Posts
    Blog Entries
    12

    Default

    I believe that's a limitation of IE. I discovered it when I was working on a script where I was appending stylesheets to the head with each change of a slide in a slideshow. It stopped working after about 30 slide changes. I ended up replacing instead of removing after the first insertion.

    At the time I had thought it was a limitation on inserting things in the head. But I have since discovered, in another script I was working on that, for example an unlimited number of script tags can be inserted.

    Something like that could be done with this script. It would be a bit of a rewrite though. Instead of switching sheets, their url's could be listed in an array or object. An object would be better I believe. Whichever sheet was to be active could be set as the href attribute of a single stylesheet link either already on the page, or that could be appended the first time it's needed, and/or that could be replaced by one with the desired href url for each change.

    When I get more time - probably later today or over the weekend, I'll do it.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    phearfactor (05-25-2012)

  4. #3
    Join Date
    May 2012
    Location
    Wisconsin
    Posts
    9
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    ok, thanks.

    We just need to get everyone to stop using IE, that would solve most issues.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,024
    Thanks
    44
    Thanked 3,209 Times in 3,171 Posts
    Blog Entries
    12

    Default

    Good luck with that. OK, this rewrite works (probably without any limits, tested with 1000 alternate sheets):

    Attachment 4464

    BTW, I double checked that there really is a problem in IE visa vis the number of sheets. There is. It's not that you cannot have a lot of sheets, rather that IE stops recognizing them as valid link tags after awhile. Amounts to the same thing. It will still count them and parse them as tags, it just won't execute their rules on the page.

    My solution was to remove them after cataloging their titles and hrefs in an object and their titles in an array.

    As a result, you can use the same markup as the original script and you don't have to set up any array or object.

    Any questions, let me know.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    phearfactor (05-29-2012)

  7. #5
    Join Date
    May 2012
    Location
    Wisconsin
    Posts
    9
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    New .js file works great! Thanks John!

Bookmarks

Posting Permissions

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