Andrew Poulos
9/4/2015 5:50:00 AM
On 4/09/2015 12:39 AM, Evertjan. wrote:
> Jake Jarvis <pig_in_shoes@yahoo.com> wrote on 03 Sep 2015 in
> comp.lang.javascript:
>
>>>> That style property reflects *inline* styles.
>>>
>>> Yes, because that was the OQ asked by the OP.
>>>
>>
>> What?
>> No ...
>
> Indeed, Andrew said 'class attribute', my mistake:
>
> Andrew Poulos <ap_prog@hotmail.com> wrote on 03 Sep 2015 in
> comp.lang.javascript:
>> When I look at the publish source I note that every piece of text is
>> wrapped in a SPAN which has a class attribute.
>
> However, whether you change only the inline styles or also the
> classes and id styles, you would have to assertain that you are only
> changing text, not images and other element-sizes. Otherwise zooming would
> do just fine.
>
> So perhaps keeping to the <span> elements would be safest for now ;-)
I'm now trying this and it seems to be ok (not working in IE 8):
var i,
j,
len,
rules;
for (j = 0; j < document.styleSheets.length; j++) {
rules = document.styleSheets[j].cssRules;
len = rules.length;
for (i = 0; i < len; i++) {
if ( /font-size/.test(rules[i].cssText) ) {
rules[i].style.fontSize =
(parseInt(rules[i].style.fontSize, 10) / 16) + "em";
}
}
}
document.body.style.fontSize = "100%";
I search for font-size rules and then convert any to EMs based on 16
pixels equals 1 em (the app only ever publishes font sizes in pixels).
Andrew Poulos