PDA

View Full Version : obj.style.cssText for Moz?


SYP}{ER
12-25-2002, 02:24 AM
I can't seem to find out the Mozilla-equiv of IE's obj.style.cssText which returns the text in the style attribute of obj.

Could someone please let me know how to do it? Thanks :)

SYP}{ER
12-28-2002, 04:27 PM
Woah, nothing?!

scroots
12-28-2002, 04:32 PM
it is probably because the the resident moz master (jkd)is currently unavailble, otherwise you would of had an answer from him by now.

i bet he will know what it is.


scroots

BrainJar
12-28-2002, 05:00 PM
Moz supports elementObj.style.cssText. You could also use elementObj.getAttribute("style").

SYP}{ER
12-28-2002, 07:01 PM
Apparently it doesn't because it's barking at me on this page:

http://rbnb.aaron-wright.com/index.php?section=genform&style=marquee

Try that in Moz, and try editing the marquee with the form I've created.

Then check your JS error log :o

jkd
12-28-2002, 07:40 PM
javascript:void(document.body.style.cssText = 'background-color: red')

Works fine in Moz.

<marquee> is an XBL-ified element in Mozilla.
/path/to/mozilla/bin/res/html.css:

/* emulation of non-standard HTML <marquee> tag */
marquee {
display: block;
-moz-binding: url('chrome://xbl-marquee/content/xbl-marquee.xml#marquee-horizontal');
}

marquee[direction="up"], marquee[direction="down"] {
-moz-binding: url('chrome://xbl-marquee/content/xbl-marquee.xml#marquee-vertical');
}


However:
javascript:alert(document.getElementsByTagName('marquee').item(0))

On that page reveals that it inherits from HTMLDivElement, instead of HTMLUnknownElement (some funky stuff must be happening in the binding).

Anyway, setting style.cssText should work fine on this element regardless, because HTMLUnknownElements also have a CSSStyleDeclaration style property.

SYP}{ER
12-28-2002, 07:47 PM
Then why am I getting that error and having my marquee stop moving?

jkd
12-28-2002, 11:15 PM
From DOM2 CSS specs (about [CSSStyleDeclaration].cssText):

The parsable textual representation of the declaration block (excluding the surrounding curly braces). Setting this attribute will result in the parsing of the new value and resetting of all the properties in the declaration block including the removal or addition of properties.


I'm taking a guess that you are removing the all-important -moz-binding property by setting cssText, though I don't see why setting cssText on an inline style should affect styles applied to it elsewhere...