Thanks Mike, that's a huge help and sounds like it will solve my
problem perfectly. I will have a play now.

Should jQuery not be clever enough to handle this internally when you
call .text() on a style element?
Is it worth filing as a bug do you think?

Andy.

On 8 Oct, 11:07, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> Andy, you can read or write the content of an IE stylesheet with:
>
>    $('style')[n].styleSheet.cssText
>
> where n is the index of the stylesheet you want.
>
> Instead of browser detection, I test for the presence of that .styleSheet
> property, and then either use .styleSheet.cssText or .text() depending.
>
> Some example non-jQuery code that I use (shows writing and replacing but not
> reading):
>
>     function addStyle( css ) {
>         var style = document.createElement( 'style' );
>         style.type = 'text/css';
>         head.appendChild( style );
>         if( style.styleSheet )
>             style.styleSheet.cssText = css;
>         else
>             style.appendChild( document.createTextNode(css) );
>         return style;
>     }
>
>     function changeStyle( style, css ) {
>         if( style.styleSheet )
>             style.styleSheet.cssText = css;
>         else
>             style.replaceChild( document.createTextNode(css),
> style.firstChild );
>         return style;
>     }
>
> -Mike> From: Andy Kent
>
> > I'm working on fixing my JSS plugin for IE, it appears that
> > IE has really problems with showing you the source of
> > stylesheets that are between style tags.
>
> > $('style').text() -> returns null
>
> > $('style').html() -> returns the source but it is modified,
> > e.g. all non-supported selectors are changed to 'UNKOWN'
> > (very unhelpful!)
>
> > Before I delve deeper into this does anyone have a work
> > around already??
>
> > I assume this is supposed to be some sort of security feature
> > but it seems very strange seeing as loading external styles
> > works as expected.
>
> > Thanks,
> > Andy.

Reply via email to