A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: domobject.js?

  1. #1
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429

    domobject.js?

    I've been grabbing a lot of scripts lately that each seem use their own flavor of DOM detection/browser sniffing. Since I don't really understand the ins and outs of how to detect and talk to anything I tend to just re-detect inside each function.

    Even if I was cool with all that extra code, there's something inherently wrong with writing commands in triplicate.
    But it looks like things are calming down and there should be enough protection for old standards if new ones come out.

    I've been using the swfobject for about a year now and I'm am still impressed every time I use it. It provides one set of commands that work in all browsers for all things flash. I dare say it's perfect.

    So I'm just sitting here wondering, where the hell is the domobject? I wrote a class that creates a Stage object that you can use just like flash's and I'm thinking, this can be done for 100% of available browser elements.

    Imagine a js import that simply creates the equivalent of _root in flash and using it, you could refer to your DOM elements just like movieclips and their properties/methods.

    There's some great stuff out there like mootools but they are usually prepackaged features, I'm looking for a once and for all, never have to think about cross browsers again fix.

    Anyone know of a project like this in development?

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    There are a number of libraries that try to hide some of the cross browser problems in Javascript/DOM scripting - I'm quite fond of YUI. It does a pretty good job of smoothing over places - like event handling and maniplulating styles - where the browsers can differ. Actually now that I think about it, the YUI event library is actually very cool. It's also nice and modular, so if your page doesn't need fancy animation effects you don't need to include the animation part of the library.

    However common to most similar libraries it likes you to write code its way, and its way requires a fair bit of typing - lots of YAHOO.util.Whatever.something() stuff everywhere.

    Another thing (it's pretty new) but might be just what you're looking for, could be Base2.DOM by Dean Edwards. Essentially instead of being a library that tries to create a bunch of neat widgets (A bit like Dojo, and to a certain extent YUI) or rework Javascript so it behaves like a different langauge (hey, prototype I'm looking at you) it just sets out to to take things that don't work quite right and fix them (and add a bunch of features that should've been there already). I haven't tried it yet, but it looks really neat.

    For example the get/setAttribute methods are pretty broken in IE. It seems you can just apply the library to your page and it'll take care of making them work properly.

    http://dean.edwards.name/weblog/2007/03/yet-another/ has the details.

  3. #3
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Those are definitely headed in the right direction.
    YUI is out because this demo doesn't work in ie6 (im using a standalone ie6 so I don't know if that is a fair test)
    http://developer.yahoo.com/yui/examp...tooltip/2.html

    I will have to test a few things out on dean edwards but he's got the right idea.
    Javascript libraries for the purpose of packaging functions and classes are great, but if I have to learn caveats and workarounds for those too, I might as well learn how to write universal script which at the moment seems impossible.

    I want something that just creates an object I can treat like a browser window. Since I'm a huge fan of actionscript, I lean on its naming so lets say the script creates an object called _ROOT. I'd like to be able to just say:
    _ROOT.myElement.width = 200px;
    without a second thought of weather or not some browser will display that.

    So it would actually be two-fold. One part would do all the cross-browser translation, the other would dynamically write the appropriate CSS complete with box model hacks. I would actually prefer to create a style object and set its properties than write CSS anyway.

    The way things are going, if you don't have javascript enabled, a style sheet isn't really needed anyway.

    I would love to just write something like:

    myStyle = new JS_STYLE();
    myStyle.width = 200px;
    myStyle.z-index = 3;

    and just not have to worry what browser is going to do what with it. The script should know to insert the appropriate hacks.

    Seems like it could be setup so that you could write div elements normally.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center