|
Posted by Thomas 'PointedEars' Lahn on 01/10/07 11:33
Neredbojias wrote:
> With neither quill nor qualm, delraydog@gmail.com quothed:
>> How can I use JavaScript to append my own style sheet information to a
>> possibly already existing stylesheet definition?
>
> That's no problem. The latest style is the one honored.
That is not entirely true. It depends on the specificity of the selectors
used.
> Add something like the following to the <head> section:
>
> <script type="text/javascript">
> <!--
> document.write('<style type="text\/css">\n#ct1 { width:95.2%; text-
> align:justify; }\n<\/style>\n');
> document.close;
document.close() refers to a Function(-like) object. The Call Operator ()
is _not_ optional for it to be called. Therefore, the object reference is
only evaluated and nothing is called, preventing the harm it would do
otherwise.
> //-->
> </script>
>
> PS: This example is from one of my pages, has been checked and works.
It probably breaks in NN4 due to the Run-Length bug. It breaks in a
conforming HTML UA due to nonsensical comment delimiter strings, and
it breaks in XHTML due to either comment delimiters (empty `script'
element), or markup delimiters like `<' in PCDATA, or document.write()
not supported there in recent UAs.
BTW: Not all / characters in script data have to be escaped, only
those in an HTML document that would form the ETAGO delimiter </
F'up2 cljs
PointedEars
Navigation:
[Reply to this message]
|