Help from my friends and random people on IE8 Dynamic CSS?

To my five fans (to those reading that aren’t part of the fan 5 crew, my 5 fans are also good friends):

I have a bit of a dilemma in some web coding.

Problem: I need to be able to dynamically inject some CSS rules into a web page through JavaScript. (Long story why, I just do.) In all of my target browsers, various methods would work to inject CSS into a web page via JavaScript. IE8 does not like any of these previous methods. The only way I’ve found so far to get this to work in IE8 is the following hacktastic solution:

    function hacktasticSolutionToDynamicCSSInjectionInIE8() {
        var myCSS = "<style>.redText{color:#ff0000}</style>";
        document.getElementsByTagName("body")[0].innerHTML += myCSS;
    }

Using the method above to inject a stylesheet into the body tag via innerHTML so makes me want to gouge my eyes out. But it’s the only thing that seems to work in IE8?

Other things I’ve tried that have failed:

Anyone reading this who knows of a better solution than what I’ve done in the hacktastic function above?

Edit: 7/3/2009
Turns out in all my tests, Internet Explorer tends to provide a “free” stylesheet by default. The following code did what I wanted on all IEs, and everywhere else.

    if ( document.styleSheets[0] && document.styleSheets[0].cssText ) {
        document.styleSheets[0].cssText += cssString;
    } else {
        var style = document.createElement("style");
        style.appendChild(document.createTextNode(cssString));
        document.getElementsByTagName("head")[0].appendChild(style);
    }

Quote of the day

JavaScript, making 1 + 1 = 11 since 1995.

Polishing the Brass on the Titanic

Brent, my friend and one of the very cool people I work with, uses the saying in the subject of this post. He was the first one who said these words and that when said they registered in my mind. This happened a couple of months ago and I’ve been thinking about this ever since. To find a little background on the saying, I decided to do a Google to the rescue… well, not this time. I couldn’t find the origin of this saying, but I did find this great quote:

Fuck Martha Stewart. Martha’s polishing the brass on the Titanic; it’s all going down, man. ~Fight Club movie, screenplay by Jim Uhls, directed by David Fincher, novel by Chuck Palahniuk

I was thinking about this (the saying, not Martha Stewart) tonight on the bus ride home from Santa Cruz and I came to accept that, yup, I’m a guy that polishes the brass on the Titanic. Sure I freak out, I rant, I swear, I cuss, I act like a dirty old man… I have human flaws too numerous to mention.

Despite my flaws, the quality of life despite the overwhelming circumstances of life has started to matter much more to me than it used to.

Say a nuke is coming in from the country run by [Insert new media sensationalized despot here], and is going to explode all over me in a half hour, what am I going to do? I’m going to find my wife and nail her one more time and give her the best 3 to 14 minutes of her life.

Say global climate change really is real and every person on the planet just decides to buy a hummer. Who fucking cares, my ass gets on my bike, and with the help of my legs helps me roll my flabby belly to the office.

What does that mean in real life? It means the little stuff matters to me because the details are all that I have access to. It means somedays I don’t release a product and instead spend more than a day QAing things even though it’s not my job to do so. Somedays I massage my wife after her hard day in the office even when I’m the tired one. Or maybe I call my dad when he’s least expecting me to call and tell him yet another thing that I realized he was right about, and I was wrong about.

Ask yourself, when was the last time you heard someone get divorced over only one big mishap?

The little things matter, at least they do to me.

Example of wonderful customer support

For my five fans,

For all of the ranting I have done about bad customer service, I wanted to show a great example of customer service. My friend Todd posted his transcript of a live chat with a Zappos agent on his blog. It is both one of the funniest, and one of the best examples of customer support that I have ever seen in my life.

http://www.sitelead.com/blog/zappos-live-chat/2009/06/01

Thanks for posting this up! And thanks to Zappos for setting a good example. If all goes my way, I will get to compare and contrast this with what I believe will be another bad service experience (if the seemingly bad place will ever respond to my customer support email-soon-to-be-emails).

Day ???: Post House Buying Review

It’s been all done for about a week. The seller’s agent has taken their lockbox to another home. The crusty plaster splattered over the plants and grass from the dry rot repairs has all been all but trampled into the ground. Wind blowing through the open (converted) garage windows has successfully cleaned the new paint smell out of what have become storage rooms. We’ve got hit with our first hefty electrical repair (it sounded a bit like this). The fig tree is getting bigger, and the jury is once again out on whether it will produce green or brown fruit. An invasion of mint (one “problem” I actually like a lot) helps move the nasty, dyed-red mulch into nice piles that Janna and I throw out bit-by-bit.

It’s definitely our house. How about some final pictures from my favorite way to do slide shows? That’s right! Zero narration. Enjoy them at your leisure.

Stripped Window

Stripped Window

Repaired Window

A ground gutter?

Repaired Corner

Final box checked

The Grass is Never Greener

I’ve been keeping these two links in my blog reader and watch the titles rise up as I click through the unread items over the passed week. The juxtaposition calms me.

Terminator Salvation (PC) Recalled

and

450 People Working on Assassin’s Creed 2

An odd pair of articles. At least I’m neither part of recalled software, nor am I lost in (what I consider) the crowd.

new blog name

I’m sure this will screw up search engines, but that’s fine because my five fans subscribe here, and everyone else just stumbles in by accident.

[Drum roll] Renaming of blog complete!

[Cheers! Applause! The sound of 10 hands clapping!]

I Like to Talk Episode 7 – Happy Birthday to Mark

A long time ago, on the internet, Rob made a fake blog. Sometime later, Rob and I made another fake blog, making fun of the original fake blog.

Today, as it nears the honest, real Mark’s birthday, I’m posting an episode of I Like to Talk that Rob and I made for Mark. It’s the most awful rendition (my fault) of Happy Birthday ever. Like in before and after Christ ever.

Happy Birthday Mark. Make sure to read through the fake blog postings we made over the last year. The question remains, just who is really the real Mark Jackman?

Download Episode 7

Day 23: Nothing has exploded

Janna and I have reached day 23 in our 35 day escrow process in the purchase of our first home. I haven’t posted very much about it because there hasn’t been much to post.

We asked for work on the house to be done prior to closing, and the repairs we asked for were accepted.

There have been no surprises. No horror stories like some of my friends have shared with me.

And maybe this is the best time to acknowledge my friend Geoff. Geoff didn’t have the worst time buying his house in San Francisco, but he didn’t have the best time either, and he told me about everything that he learned during the process, like:

In short Geoff told me about every mistake he made, everything he would do differently the next time he buys a house. He must have spent more than a handful of hours total from all of the discussions we had, all of them having one central theme: be critical when buying a house.

Not critical like negative, rather critical like serious. Critical like honorable. Critical like dealing with each and every thing that comes up, no matter how difficult it is.

Sure, accidents in life can happen, but this buying a house thing has made me wonder what would the rest of life be like if we just took it a bit more seriously than we currently do.

A man’s bathroom

King Cobra, where it belongs.King cobra on the ground

← Previous PageNext Page →