[haXe] Another haxeJs newbie question
Axel Huizinga
axel at 3drachen.de
Mon Dec 3 23:36:02 CET 2007
Franco Ponticelli schrieb:
> I've not tested it but I suspect that the stylesheets field is
> mispelled ... I think the correct name is styleSheets. If it is so you
> have to change its definition in the haxe/js/Dom.hx file.
>
> About your second question you will have to implement your solution.
> The JS API in haXe is quite essential. I suggest you to take a look at
> how big libraries deal with that problem and implement your solution
> in haXe.
>
> Franco.
>
> On Dec 3, 2007 6:21 PM, Axel Huizinga <axel at 3drachen.de
> <mailto:axel at 3drachen.de>> wrote:
>
> Hi,
> first I wonder why
>
> var a:HtmlCollection<StyleSheet> = js.Lib.document.stylesheets;
> trace(a);
>
> reports null though I have one external stylesheet linked to my html
> document.
>
Ok changing to styleSheets solved the first.
But I still have some trouble to implement the rules access.
Started with mozilla compatible syntax:
var a:HtmlCollection<StyleSheet> = js.Lib.document.styleSheets;
trace(a);
if(a!=null)for(i in 0...a.length)
{
trace(a[i]);
for(j in 0...a[i].cssRules.length)
{
trace(a[i].cssRules[j].selectorText);
//a[i].rules[j].style.color = 'red';
if(a[i].cssRules[j].selectorText == '.menuItem'){
a[i].cssRules[j].style.color = "#FFFFFF";
a[i].cssRules[j].style.backgroundColor = "#FF0000";
a[i].cssRules[j].style.fontSize = config.get('font-size');
a[i].cssRules[j].style.padding = config.get('padding');
var props:Array<String> =
Reflect.fields(a[i].cssRules[j].style);
trace(props.toString());
}
}
}
works partially. The padding and fontSize is applied but the
color/backgroundColor not!
trace of the style fields reports: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
Any more hints?
Axel
> And then I'd like to change stylesheet rules via javascript.
> Is there a way to do this with haxe?
>
> Cordially,
> Axel
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
>
More information about the Haxe
mailing list