[Javascript] targeting DOM-aware browsers [WAS: setting select drop selectedIndex]

Paul Novitski paul at juniperwebcraft.com
Wed Aug 2 16:12:10 CDT 2006


At 12:21 PM 8/2/2006, Peter Brunone wrote:
>    Why would you want it to die just because the browser isn't up 
> to date, when there are perfectly valid methods for finding the 
> control through the form object?


Peter,

You're right.  Of course anyone wanting to target pre-DOM browsers 
will want to include pre-DOM syntax.  If all you're doing is pointing 
to a form element's properties, you don't need the DOM.  However, I 
was assuming that the original poster's script would accomplish much 
more and would likely require DOM methods before it was done.  My 
scripts nearly always do.  If a script is going to need the DOM, it 
might as well boot out the older browsers from the beginning [at 
least from the DOM sections of code].

When I first started writing JavaScript several years ago, I took 
pains to support both DOM and non-DOM browsers.  Today, though, I 
find it much faster & easier to code only using the DOM, ignoring the 
older conventions.  Perhaps that confession convicts me as a slacker, 
but I am so overloaded with programming work that streamlining my 
coding practices has a significant effect on my quality of 
life.  I'll defend my current habit of targeting only DOM-aware 
browsers with just this point:

My take on the stats is that the population of browsers that aren't 
DOM-aware (< 4%?) is even smaller than the number of DOM-aware 
browsers that have JavaScript turned off (about 7%).

See for example:
         http://www.thecounter.com/stats/2006/July/browser.php
compared to:
         http://www.thecounter.com/stats/2006/July/javas.php

I endeavor to write only non-obtrusive JavaScript these days, so my 
pages remain functional in the absence of JS.  People using 
non-DOM-aware or non-JS-enabled browsers might experience less speed 
-- they'll have to wait for a server round-trip instead of getting 
instant validation -- or fewer bells & whistles, but they'll 
experience a perfectly valid & usable page.  Working in this way 
reduces my sense of obligation to target legacy browsers.

If you have an argument to the contrary, I'm all ears.

Regards,
Paul  




More information about the Javascript mailing list