Child Scripts Making Child Scripts!

I’ve been wrestling with a bug in one of my modules for AIM Pages for_ever_, and just found a fix today. I created this well-intentioned module called code snippet that allows you to paste in markup and it’ll get inserted into the DOM. This is really just a stopgap to allow people to add stuff that a module doesn’t exist for yet. I never should have written it. Do you know how bad DOM support is in IE? It’s awful!\
The big problem is that people wanted/needed to insert script elements with inline script using the code snippet module, and I couldn’t figure out a good way to do it (ok, any way, good or otherwise). Just adding them to the DOM using innerHTML doesn’t work. IE won’t allow you to create a new script element and set the text content to the code.\
Today, I stumbled on a message board post that hints at the answer. What’s the answer?\
Create a new script element, and set the text property to the script content and then append it to the body. Voila, actual evaluated javascript! Here’s an example:

<code>var b=document.getElementsByTagName("body")[0];
var txt="function doIt(msg) {alert(msg)}";
var scr=document.createElement("script");
scr.setAttribute("type","text/javascript");
scr.text=txt;
b.appendChild(scr);</code>

Enjoy! Oh, and the fixed version of the module isn’t live yet. I’m letting the QA guys look at it first before I unleash it on an unsuspecting world.

Truly Semantic Classes and Ids

Just a little thought before leaving for work. How funny would it be if we used truly semantic classes and ids in our XHTML? Instead of pretending it’s a “container” or “event-holder” or whatever other text we use to try to fool ourselves into semantic meaning, what if we were truly honest about the role that element was playing? For example:

  • im-no-css-jedi
  • because-multiple-background-isnt-implemented
  • ie-wont-clear-this-damn-thing
  • i-can-hang-another-background-off-this
  • bottomless-pit-for-my-dom-wickedness
  • should-have-been-a-list
  • because-ive-never-heard-of-fieldset
  • must-have-rounded-corners\
    I think it’ll catch on. Got more?

Howdy

Why My Site Has Been Down

Deep Thought

Presentation Remote Solved

Instead of forking over over \$30 for a new remote to use for presentations, I found mira a little System Preference pane that lets me map the buttons on my brand new MacBook Pro’s remote to other applications. It took about 45 seconds of fiddling to get forward/back mapped to the up and down arrows and voila, I have a presentation remote.\
I love Mac developers. If I’ve got a problem, there’s usually a beautifully designed easy to use solution already out there.

Where’s the beef?

SxSW Panel Online Finally!

You can go get the audio from our panel at SXSW (Convincing Your Company to Embrace Web Standards to get the slides) over on their podcasts page, or get the mp3 directly.\
I just listened to it (Steve listened to it to too, and we traded jokes) and here are my totally shallow observations after listening to myself:

  1. I did a really good job of not talking fast. I talk much faster than that normally.
  2. I sound a little bit like Kevin Smith and that kind of scares me.
  3. Note to self: don’t laugh into the mic
  4. Don’t encourage Marc Canter. No good can come of it
  5. My panelists kicked ass.
  6. Jeremy Keith loves Mr. Chipman\
    It makes me want to do a panel next year… even though it was really stressful getting this one together.\
    Update: Steve and got a transcript from Casting Words, you can go look at it if you want.

Thought of the day

Rails, Wow

I’ve been flirting with it for a while (have had the book since it came out and installed Rails all over the place, just never had time to get into it), but last night I broke down and built my first web application with Ruby on Rails and all I have to say is wow. That was way easier than it should have been. Granted, it was painfully simple, but still, it was about an hour total between setting up the domain and database on Dreamhost to getting it tweaked and looking like I wanted (oh, and working). It was another 5 minutes with the book this morning to get the export feature working like I wanted (well, they wanted).\
Next time I need to build something outside of work (or hell, maybe inside of work), it’ll most likely be in Rails.