getStyle() in Opera and IE

3 views
Skip to first unread message

ankit

unread,
Jun 30, 2009, 10:59:59 AM6/30/09
to MooTools Users
I am trying to replace a piece of text with a text-field which will
contain the same text with the same font-style, size, etc.

To do this, I'm using something similar to 'element.getParent
().getStyles('font-family','font-style','font-weight',
'font-variant','font-size','text-transform','letter-spacing');' and
then applying the same style to the text-field. Here 'element'
contains the text that is too be replaced. So I'm trying to get the
font related properties of the immediate parent.

This works properly in Safari, Firefox and Chrome. But, it doesn't
work in IE or Opera ( 9.64 ). The text is random sized and generally
'null' values are returned for most properties.

Here is the piece of code I'm using -> http://paste.mootools.net/f75d20145

Maybe there is a more foolproof way that I can implement this. Thanks!

Fábio Costa

unread,
Jun 30, 2009, 11:05:11 AM6/30/09
to mootool...@googlegroups.com
If i were were you i would define a class with text-family, text-size, etc... and set it to the text you want, then set the text to the text-field and set its value to the correct text.



Fábio Miranda Costa
Engenheiro de Computação
http://meiocodigo.com

ankit

unread,
Jul 3, 2009, 3:33:39 PM7/3/09
to MooTools Users
I would do that too. But I have to make this script work with
different independent templates. And so, I cannot predefine a class
with the text-family, etc. Rather, I have to dynamically get the font
style when I click on a title/text.



On Jun 30, 8:05 pm, Fábio Costa <fabiomco...@gmail.com> wrote:
> If i were were you i would define a class with text-family, text-size,
> etc... and set it to the text you want, then set the text to the text-field
> and set its value to the correct text.
>
> Fábio Miranda Costa
> Engenheiro de Computaçãohttp://meiocodigo.com
Reply all
Reply to author
Forward
0 new messages