From: Thomas 'PointedEars' Lahn on
Scott Sauyet wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Scott Sauyet wrote:
>>> I'm probably missing something obvious, but I don't know of a simple
>>> cross-browser technique to copy the content of one stylesheet into a
>>> new STYLE element. Obviously in IE, we can just copy in
>>> styleSheet.cssText. But I don't think the other browsers support
>>> cssText on the whole sheet, just on the individual rules. Is there
>>> some simpler method to do this?
>>
>> Suppose !styleSheet.href and you are right about `cssText', in a
>> nutshell:
>>
>> var
>> s1 = styleSheet,
>> s2 = document.createElement("style");
>>
>> if (s1 && s2)
>> {
>> s2.type = "text/css";
>> s2.appendChild(
>> s2.createTextNode(s1.cssText || s1.ownerNode.textContent));

Should be document.createTextNode(...), of course.

>> document.getElementsByTagName("head")[0].appendChild(s2);
>> }
>
> Ahh, very nice. I hadn't run across ownerNode before. This is
> clearly the simplest solution.
>
> Thank you for taking the time to post it.

You are welcome.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
From: Jorge on
On Jan 11, 6:32 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> (...)
> s2.createTextNode(s1.cssText || s1.ownerNode.textContent));
> (...)

"ownerNode of type Node, readonly (...) For style sheets that are
included by other style sheets, the value of this attribute is null."

"parentStyleSheet of type StyleSheet, readonly
For style sheet languages that support the concept of style sheet
inclusion, this attribute represents the including style sheet, if one
exists.(...)"

Therefore, me thinks:

IZ s1.ownerNode ?
YARLY
s1.ownerNode.textContent
NOWAI
s1.parentStyleSheet.ownerNode.textContent
KTHX
--
Jorge.
From: Thomas 'PointedEars' Lahn on
Jorge wrote:

> Thomas 'PointedEars' Lahn wrote:
>> (...)
>> s2.createTextNode(s1.cssText || s1.ownerNode.textContent));
>> (...)
>
> "ownerNode of type Node, readonly (...) For style sheets that are
> included by other style sheets, the value of this attribute is null."
>
> "parentStyleSheet of type StyleSheet, readonly
> For style sheet languages that support the concept of style sheet
> inclusion, this attribute represents the including style sheet, if one
> exists.(...)"
>
> Therefore, me thinks:
>
> IZ s1.ownerNode ?
> YARLY
> s1.ownerNode.textContent
> NOWAI
> s1.parentStyleSheet.ownerNode.textContent
> KTHX

Think again.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
From: Jorge on
On Jan 11, 7:18 pm, Jorge <jo...(a)jorgechamorro.com> wrote:
> (...)
>   NOWAI
>     s1.parentStyleSheet.ownerNode.textContent
> KTHX

Hmm, that would be the parent styleSheet not the child, therefore...

NOWAY
BTW WAZZUP ?
KTHX

Copy rule by rule ?
--
Jorge.
From: Thomas 'PointedEars' Lahn on
Jorge wrote:

> Jorge wrote:
>> (...)
>> NOWAI
>> s1.parentStyleSheet.ownerNode.textContent
>> KTHX
>
> Hmm, that would be the parent styleSheet not the child, therefore...
>
> NOWAY
> BTW WAZZUP ?
> KTHX
>
> Copy rule by rule ?

I have a fair idea now why you are continually running into walls.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee