reference, on javascript and dom

Z

Zhang Weiwu

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.getElementById("selector").add(newoption)

Here the add method is not mentioned in gecko reference.
 
M

Michael Winter

Perhaps gecko is the closest to w3c recommendations (if not Amaya)?

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).
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.

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.
For example of in-completeness of gecko reference: I once saw someone
coded like this:
var options = new Options();

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.createElement('OPTION');
However Options type of object is not mentioned in gecko reference.

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

Also:
document.getElementById("selector").add(newoption)

I expect that's the HTMLSelectElement.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.
Here the add method is not mentioned in gecko reference.

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

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,338
Latest member
41Pearline46

Latest Threads

Top