I struggled with this for quite a while. If you’re looking to do the typical:

var newLink = document.createElement("img");
newLink.setAttribute("onclick", "alert('You clicked me')");

You will be upset to discover this works in Firefox and IE 8, but not IE 7 or IE 6. After some Googling I found a nice explanation by Justin French.

The fix:

var newLink = document.createElement("img");
newLink.onclick = function() { alert("You clicked me"); }

Thankfully this works for Firefox and IE 8-6.


As the 1 or 2 of you who read my blog know I recently created my own wordpress theme. Being that I’m NOT a CSS guru and I’ve pretty much taught myself everything I know about CSS, I made a few mistakes along the way. Pretty much everything went well, except my site fails XHTML validation (click the link at the bottom.. FAIL). So it turns out one of my problems is using ids in my divs vs. using classes.

I’ve always been under the impression that an id was used for most divs, and other tags for that matter, and classes were just used sparingly. But to my surprise, ids should only be used once on a page while classes are used in multiple locations. After pondering this for a bit, it does seem to make logical sense to have it this way.

For instance, lets say I had a container div and a entry div. The container just wraps the entire page so you could, for example, have the layout constantly centered and the entry wraps different comment posts on a page. Since the container is used only once on the page we would want to define this with an id and since the entry is used in multiple comments we would want to define this with a class.

<div id="container">
  <h1>Some container heading</h1>
  <div class="entry">
    <h3>Some entry heading</h3>
    <p>Some comment</p>
  </div>
  <div class="entry">
    <h3>Some other entry heading</h3>
    <p>Some other comment</p>
  </div>
</div>

The same should be done for other tags as well, such as spans, p tags, headings, etc. After I fix these problems on my site I will retry the XHTML validation and see what happens. Good luck to everyone else.


I decided to use my CSS / PHP / Photoshop skills and create my own wordpress theme. This design was originally created for my portfolio site, but I figured I might as well use wordpress for easy content management and add the pages I wanted for the portfolio site on top of the blog. I even busted out the old flash skills. Hope everyone enjoys it.

On another note, I will be heading to the Smokey Mountains in NC for a little cabin vacation then off the Andrea’s friends baby shower. I’ll try to update with pics from the mountains and any other happenings while I’m gone.. then it’s back to school.