reference, on javascript and dom

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zhang Weiwu

    #1

    reference, on javascript and dom

    Hello. I often need to write cross-browser javascript, so far gecko dom
    reference is the reference seems mostly suite me, for things running
    well on gecko are likely to be running well on other engines. Perhaps
    gecko is the closest to w3c recommendations (if not Amaya)?

    Now it seems many of javascript/dom is not converted by gecko reference.
    So what reference do you use? I want a very complete reference for web
    scripting in HTML document authoring, but not so detailed as
    recommendation itself.

    For example of in-completeness of gecko reference: I once saw someone
    coded like this:
    var options = new Options();
    However Options type of object is not mentioned in gecko reference. Also:
    document.getEle mentById("selec tor").add(newop tion)

    Here the add method is not mentioned in gecko reference.
  • Michael Winter

    #2
    Re: reference, on javascript and dom

    On Wed, 27 Oct 2004 23:41:31 +0800, Zhang Weiwu <zhangweiwu@rea lss.com>
    wrote:
    [color=blue]
    > Perhaps gecko is the closest to w3c recommendations (if not Amaya)?[/color]

    Opera is very good, too, but it does emulate some of Microsoft's DOM and
    script "features".

    Amaya isn't particularly good. It has no ECMAScript support, and it's CSS
    implementation isn't complete (even IE has better support in some
    respects).
    [color=blue]
    > Now it seems many of javascript/dom is not converted by gecko reference.
    > So what reference do you use? I want a very complete reference for web
    > scripting in HTML document authoring, but not so detailed as
    > recommendation itself.[/color]

    I'm afraid I only use the W3C Recommendations . I doubt there is anything
    as comprehensive, so it might be an idea to try and learn to understand
    it. Certainly do not trust Microsoft's DHTML Reference (if anyone
    recommends it in this thread). It doesn't conform to the DOM, sometimes
    even when entries state they do.
    [color=blue]
    > For example of in-completeness of gecko reference: I once saw someone
    > coded like this:
    > var options = new Options();[/color]

    I would imagine it was:

    var option = new Option();

    This is a remnant of "DOM 0", specifically Netscape's JavaScript. In newer
    browsers, it's directly equivalent to:

    var option = document.create Element('OPTION ');
    [color=blue]
    > However Options type of object is not mentioned in gecko reference.[/color]

    Though the DevEdge web site is dead, you can read the v1.3 reference using
    the "Wayback Machine" (<URL:http://web.archive.org/>):

    <URL:http://web.archive.org/web/20040202050531/devedge.netscap e.com/library/manuals/2000/javascript/1.3/reference/>
    [color=blue]
    > Also:
    > document.getEle mentById("selec tor").add(newop tion)[/color]

    I expect that's the HTMLSelectEleme nt.add method, used to add newly
    created OPTION elements to a SELECT element. You should know, however,
    that the actual interface is:

    add(newOption, referenceOption )

    where referenceOption refers to the OPTION that will end up positioned
    *after* the new OPTION. Specifying null adds the new OPTION to the end of
    the list.

    This is an example where IE is non-conformant. IE allows the the second
    argument to be optional (it must *always* be specified, even if null), and
    it uses a number not an object reference. To be able to use the add method
    effectively, you have to use try/catch to catch the exception thrown if
    you use the W3C approach in IE, or the IE approach with other browsers.
    Because of this, it's probably better to use appendChild or insertBefore,
    instead.
    [color=blue]
    > Here the add method is not mentioned in gecko reference.[/color]

    No. Most elements, and their members, aren't.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    Working...