You are missing the point entirely. It doesn't matter if you define
the secondary stylesheets as alternate or not, it doesn't change the
behavior of those selectors.

Using the DOM, it seems like all major browsers provide the
styleSheets interface, but not uniformly.

For the sake of anyone else who's dealing with this in the future I'll
post my findings.

document.styleSheets:

Firefox and IE8:
  Correctly list each stylesheet and set the disabled attribute
appropriately (e.g. stylesheets which arent applied are disabled=true)

Webkit (Chrome/Safari):
  Only lists the first non-alternate stylesheet (regardless if it is
applied applied) the disabled attribute seems to only be applied
correctly in certain situations.
   For example if you list two stylesheets, both rel="stylesheet" and
the first media="print", it adds the print stylesheet to the list, but
claims disabled=false (despite it not being applied or applicable).
   If you list two stylesheets both with rel="stylesheet" and both
with media="screen" it applies the first, adds it to the list and
correctly sets disabled=false.
   If you use jquery to set disabled=false to the second stylesheet
link, it will then be added to the styleSheets object properly with
disabled=false.
   If you set disabled=true to any stylesheet link, it will be removed
from document.styleSheets.

   In effect, Webkit only seems to keep the currently applied
stylesheets in document.styleSheets (regardless of media type)

Opera:
  Provides the document.styleSheets, but does not seem to put anything
in it under any circumstances I was able to try.

So currently the only manageable workaround that works across all
browsers to change stylesheets is as follows:

1. Turn off all active style styles (you can also filter by title
etc.) by disabling their parent link:

$('li...@rel*=stylesheet]:enabled').attr('disabled', true);

2. Turn on the style you want by using the title attribute (or media,
href etc.)

$('li...@rel*=stylesheet][title="theme"]').attr('disabled', false);

Hope this helps others with the same problem.

In the future I hope Opera and Webkit emulate the document.styleSheets
functionality that IE and Firefox do, but I'm not holding my breath.

Cheers,
-Max



On Sep 1, 5:47 pm, Badbeer <insyn...@gmail.com> wrote:
> Yes, "alternate stylesheets" vice just defining as "stylesheet" SHOULD
> make no difference but it does. Not all browsers work the same or
> follow standards, if they did, website design would be easy and ...
> we'd have a flood of people calling themselves website developers.
>
> On Sep 1, 5:07 pm, max goldberg <m...@tnug.com> wrote:
>
> > That makes no difference, "alternate stylesheets" are just that, given
> > the two options, every browser I've tried properly applies the
> > rel="stylesheet" and does not apply the rel="alternate stylesheet". IE
> > and Chrome both still return false positives when using :enabled.
>
> > Firefox and IE (and I'm assuming most other major browsers) provide
> > functionality to change stylesheets (in Firefox View->Page Style and
> > IE View->Style), these browsers clearly have an internal
> > representation of which stylesheets are applied and which aren't, it
> > just isn't clear how or if it is possible to access that information.
>
> > So far Firefox is the only browser which seems to apply the disabled
> > attribute to stylesheet declarations which are not currently applied.
> > There still seems to be no way to figure out on other browsers which
> > stylesheets are applied without setting them all to disabled=true and
> > then setting the one you want applied to disabled=false, which seems
> > like a big hack.
>
> > On Sep 1, 4:20 pm, Badbeer <insyn...@gmail.com> wrote:
>
> > > > <link type="text/css" rel="alternate stylesheet" href="theme.css"
> > > > title="theme" />
>
> > > I just noticed it... FF and other browsers don't know what to do with
> > > "alternate stylesheet" and don't load it. Make it just "stylesheet"
> > > and it will work.- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to