Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Style object

  1. #1
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post

    Style object

    I wish to construct a tree from a styleSheet object.
    Each node will be a selector which will have rules as child nodes.

    Do I have to iterate through each of the rules from the styleSheet object and create a compare the selector name with the previous in order to do this? Are there methods or properties for navigating a styleSheet object like an element? Like, being able to just traverse each selector and fetch the rules for each?
    Omnis mico antequam dominus Spookster!

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Well, it's a tree already. Iew uses it's own object model, Opera doesn't and won't support programmatical access to style sheets for op9 and earlier, moz uses a partial (pretty full actually, but wrong in some details) implementation of the W3C object model, and I've not got any idea about saf.

    The iew model:
    <uri:http://msdn.microsoft.com/workshop/a...tylesheets.asp>
    <uri:http://msdn.microsoft.com/workshop/a...stylesheet.asp>

    The W3C model:
    <uri:http://www.w3.org/TR/DOM-Level-2-Style>
    In which you're mostly interested in this part:
    <uri:http://www.w3.org/TR/2000/REC-DOM-Le...01113/css.html>


    Basically, for what you want to do, you just need to know a few differences between the object models. The iew model uses oStyleSheet.rules and the W3C model uses oStyleSheet.cssRules for the rule list. Both use oRule.selectorText for accessing the selector part of the rule set.

    They differ in several other parts though, and sometimes the documentation isn't that good.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    They differ in several other parts though, and sometimes the documentation isn't that good.
    Unfortunately, yes... In a similar attempt I had to check step by step every assignment, method. And, yes, I have sensed the Opera's low response on it... If you meet some further problems on your try ,Mhtml, post them here, maybe some of us has already bypassed them
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #5
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Sweet, thanks guys. I'm not too worried about cross browser compatability. I'm just writing a few tools to speed up my development times so it really only has to run on FF to start with till I port them to C++.
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •