[thelist] How evil is innerHTML (was JavaScript/Ajax - responseText...)

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Thu Mar 2 13:46:12 CST 2006


Well, that makes sense... but all it really tells me is that innerHTML is to be avoided *for certain tasks*.  Hopefully we try to avoid the "everything is a nail" mentality, so there are good applications to be found.

> It's also more fun. 

I get a rush from adding all that markup in one line of code, but then again I'm kooky like that :)

Peter

 From: "Matt Warden" mwarden at gmail.com

On 3/2/06, EasyListBox.com Peter Brunone wrote:
> I'm curious -- why the aversion to innerHTML?
>
> From: "Matt Warden" mwarden at gmail.com
>
> I'm not sure how to help you, because I avoid innerHTML like the plague.

A starter:

http://www.google.com/search?q=innerhtml+%28evil+OR+devil%29

But, mainly, my problem is that it ties your entire ajax chain to the
markup you are using. For example, imagine needing to change from
HTML4 to XHTML if your markup is spread between your actual HTML
pages, your JavaScript, and also the server-side of your AJAX
application.

Using DOM methods is not only standard, but it is an abstraction from markup.

It's also more fun.

Matt Warden



More information about the thelist mailing list