[thelist] AJAX Tip

Lee kowalkowski lee.kowalkowski at googlemail.com
Thu Apr 6 06:38:49 CDT 2006


On 06/04/06, Christian Heilmann <codepo8 at gmail.com> wrote
>
> > It's fine to say something is DOM Scripting if it actually use the DOM,
> but
> > not if your doing non-DOM DHTML unobtrusivesly, that would be lying.
>
> How do you NOT use the DOM when you want to do unobtrusive Scripting?
> Even if it is DOM-1?


Hmm, let's see...

<a href="picture.jpg" onclick="return showPicture(this, 'picture.jpg');"><img
src="thumbnail.jpg" /></a>

perhaps?

Really contrived, but showPicture could be:

function showPicture(elem, src)
{
  if(typeof elem.innerHTML == 'undefined')
  {
    elem.innerHTML = '<img src='"+src+"' />';
    return false;
  }
  return true;
}

Okay, that's a pretty lousy example (I'm really ashamed of it already), but
it's unobtrusive i.e. javacript is not breaking the page.

I might have misunderstood the DOM Scripting message, but I thought one
factor was to discourage the use of innerHTML (which is not DOM).  Purists
would say that if you use innerHTML, it's not pure DOM Scripting.

On the other hand, it would be futile to avoid getElementById() or
getElementsByTagName() in this day and age in order to use innerHTML, so
yeah, DHTML with absolutely no use of the DOM is unlikely.  I was being
picky.

-- LK



More information about the thelist mailing list