[Javascript] Best Practices

Triche Osborne wdlists at triche-osborne.com
Mon Apr 17 13:49:20 CDT 2006


Paul Novitski wrote:
> Triche, my sense is that the Best Practices in this case are:
> 
> 1) Set up your application to run perfectly in the absence of DOM-aware 
> JavaScript: when selections are made, post the page back to the server 
> which returns it with the correct number of input fields built into the 
> page.
> 

Thanks for the can opener, Paul. ;-) I wanted to think about my response
a bit because this remark and a concurrent discussion of progressive
enhancement on another list opened a can of worms that I've kept shelved
for too long.
	I suppose I should be clear to that I'm not reacting negatively to the
advice above. On the contrary, it's something I would do anyway, and it
doesn't even present the sort of conflict that I've been pondering. It
did remind me of it, though, so maybe it's time to deal with the worms.
	Pertinent to this list are those issues that deal with areas of
accessibility and modernity. The increasing emphasis on separating code
from mark-up (which I like) does rely heavily on the DOM. This is fine
in cut-and-dried cases like the one I mentioned, where one can easily
compensate for non-DOM browsers with a little server-side work, but
suppose the issue were validation instead? Do you . . .
	(1) attach onchange and/or onsubmit events through an external script
using the older forms collection and use alert-style messages instead of
pretty DOM errors;
	(2) or go DOM the whole way and let the server-side sticky validation
catch the non-DOM users?
	Re: graphic button image swaps: Do you . . .
	(1) use the old style of wrapping the image in an anchor tag which
contains omo/omo events;
	(2) attach the omo/omo to the anchor via the DOM so that, although
non-DOMs can't see the swap, the button still works;
	(3) or go DOM all the way, attaching the omo/omo/onclick behaviors
directly to the image? Although this latter disables the buttons, it
does not disable the functionality of the text links which you have (of
course you have) included for text-only users.
	Perhaps it's just me, but areas like these seem fuzzy and ill-defined.
Maybe I just need a new pair of reading glasses, but most of what I see 
written about modern scripting is either philosophical and/or advocating 
a particular point of veiw rather than addressing practical aspects of 
implementation. Anyone have any thoughts, practices, etc. to offer?

Triche





More information about the Javascript mailing list