DOM ? HTML DOM

M

mk834tt

Beginner here.

Core DOM and HTML DOM. (I'm not sure I've even phrased these
questions correctly. Please feel free to read between the lines.)

The core DOM contains getAttribute() and setAttribute() and is
designed to work with general documents. It "should" work with HTML
if implemented. Correct?

HTML DOM works only with HTML documents. It does not use accessor
methods but allows direct access to parameters. Correct? (as in
obj.className = "popup")

It was suggested that it is safer, more universal, to use HTML DOM and
the direct access construct in HTML pages. Correct?

A suggestion to use core DOM methods exclusively (which is nice and
regular - I'd like to) is not a good idea if you want to support
multiple browsers. Correct?

Thanks
 
R

RobG

Beginner here.

Core DOM and HTML DOM. (I'm not sure I've even phrased these
questions correctly. Please feel free to read between the lines.)

The core DOM contains getAttribute() and setAttribute() and is
designed to work with general documents. It "should" work with HTML
if implemented. Correct?

More or less, yes. It provides a specification for interfaces exposed
by DOM objects, HTML is one way of specifying the document that is
used to build the DOM. XML is another and no doubt you could do it
with Postscript but who is enough of a masochist to do it? :)

HTML DOM works only with HTML documents. It does not use accessor
methods but allows direct access to parameters. Correct? (as in
obj.className = "popup")

It works with objects that implement HTML interfaces. I guess
strictly it doesn't matter what the underlying mark-up is, as long as
it is built into an HTML-compatible DOM.

It was suggested that it is safer, more universal, to use HTML DOM and
the direct access construct in HTML pages. Correct?

I'm not sure what you mean by "the direct access construct".

Generally, it is best to use DOM methods, however there are times and
places that innerHTML is of great value. The argument is usually over
where to use one or the other. If you find yourself getting an
element's innerHTML, munging the text string, then re-inserting it,
you should have used DOM.

A suggestion to use core DOM methods exclusively (which is nice and
regular - I'd like to) is not a good idea if you want to support
multiple browsers. Correct?

No.

There are places where you can use innerHTML as a fall-back if feature
testing shows certain DOM methods aren't supported or are known to be
buggy, but I don't think as a general strategy using one to the
exclusion of the other provides greater cross-browser support.

Certainly there are many things that are simple using DOM that would
be extremely complex if string manipulation and innnerHTML was used.
The opposite is so.

innerHTML tends to be faster on some browsers (and hugely for a few)
but that is mostly because their DOM implementations are sloth-like.
In browsers like Safari, DOM is about the same speed as innerHTML
(which used to be because its innerHTML was desperately slow, but not
now - both are speedy).
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top