[thelist] How do I know if a piece of JS is DOM or browser specific?

Timothy J. Luoma lists at tntluoma.com
Tue Oct 15 14:01:10 CDT 2002

Peter-Paul Koch wrote:

 >> I'm trying to learn how to play with the DOM, but I want to avoid
 >> any browser specific stuff and code "W3C" DOM.
 > For the moment you cannot ignore browser specific stuff, or your
 > sites won't work in Netscape and Explorer 4.

I have the luxury of not caring :-)

The site I am working on is a personal just for myself, and will be
XHTML served as application/xhtml+xml which means that even IE6 won't
even be able to handle it, nevermind earlier browsers.  (Since I avoid
IE whenever possible, this is not a big deal to me.)

 > The W3C has only standardized a DOM for XML documents (and since HTML
 >  documents are XML documents, it also works on HTML). However,
 > window.open is a quite different part of JavaScript, properly
 > speaking it isn't part of the DOM since it's not about documents but
 > about browser windows.

good point...

 > If they work in all browsers they're valid.

'all browsers'?  I'm sure this means that you have to choose what subset
of browsers you are going to support/test on...

What about Mozilla 2, Internet Explorer7?  Opera 8?  Konqueror 5?

My idea was to start learning the "standards" so as to not end up with
the javascript equivalent of using tables for layout, only to have to
un-learn bad habits later.

 > There is no validator or such for JavaScript, thank God.

Well I figgered as much... suppose it would be pretty hard to do.  The
nice thing about the validator is that you can say "Hey, I wrote this to
the standards, it's your browser that's broken."

Since my primary browser is Opera, I'm also trying to figure out where
it needs to improve its support for JS/EMACScript/DOM.

 > I think you should start with a simple JavaScript book. First get the
 > basics, don't worry too much about the DOM. Then, when you can write
 > simple scripts, go on to more complex things like DHTML, and only
 > then tackle the W3C DOM.

Given the above, is that still your recommendation?  Most of the
examples I've seen are of the type:

"Ok, now if you want to do X, you do A for NN4, B for IE4, C for IE5,
and D for all others."

which would be great if I was trying to land a job writing real world
JS, but I'm looking to expand my mind in my extremely limited, so-called
"free" time.

That said, if there are good JS books that teach principles, etc, I'd
love to hear what they are... searching for "DOM" in Google can be
inefficient at best and.... err.... um... surprising, shall we say, at
worst.... suffice it to say I've familiarized myself on how to tell
Google to /exclude/ some things from search results :-)

What would you consider a good 'simple JS book'?



ps to PPK -- much of the useful stuff I have found thus far has your
name on it.  Just to say 'thanks' from a 'starting at zero' newbie.

OperaBlog: Beyond30                      http://tntluoma.com/beyond30
30 Days to becoming an Opera Lover     http://www.tntluoma.com/switch
Opera Panels / Sidebars                  http://tntluoma.com/sidebars

More information about the thelist mailing list