Out from under the carpet

I’ve been crazy busy lately with projects at We-Create so my RSS feed reader has been quickly filling up with unread posts. I finally took a bit of time tonight to re-visit it and came across a few gems I thought I’d share.

Debugging JavaScript

Jesse Skinner over at The Future of the Web had a great little post on debugging javascript. Basically by adding a simple function to your site:

function debug_mode() {
    return location.hash == '#debug';

}

you can degub any code JavaScript:

if (debug_mode()) {
    alert('alert away!');
}

and all you have to do is add #debug to the URL. Brilliant! That’s kinda an obvious thing to do so I’m not sure why didn’t I think of it. Thanks Jesse.

DOMAssistant 2.0

Robert Nyman wrote me awhile back to let me know that DOMAssistant version 2.0 has been released. New features include:

  • Chainability
  • AJAX Module
  • Easier DOMReady
  • XPath Support

These make for some great additions to the little library, good work Robert and team.

No events with innerHTML

Friendly Bit had a post about events disappearing after using innerHTML to modify the DOM. When you add events using the event attribute and then modify the parent’s innerHTML property, it seems that you’re events all go bye-bye. Check out the article for a better explanation but it’s just another reason to avoid innerHTML altogether.

1 Comment »

  1. The innerHTML info would be great to have in a book titled Advanced DOM Scripting.;-) I’m kind of surprised it’s not there.

    However, in passing around a “challenge” based off Emil’s code, I saw many people thinking because they were using the paragraph element’s innterHTML that they were simply adding to the end of the paragraph, thinking the span with the class of clickspan would simply keep its associated event.

    But aren’t you actually replacing the element with the innerHTML in this case, with a span that looks exactly the same as the original? And the code doesn’t reassign the onclick to it, so it kind of makes sense.

RSS feed for comments on this post. TrackBack URI

Leave a comment

© Copyright 2007 Jeffrey Sambells.