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 8 - Green Eggs and Ham

Yes I have pictures to post. Yes I miss my 5 most dedicated fans. Here’s to my 5 fans out there, as it’s been too long since I’ve posted something.

Decided to post something that makes me happy for a change. Only video this time, at least until I can figure out how to rip an audio track from a video.

I Like to Talk Interlude: New House

Going in reverse media order, I took this on the day we got the keys to our new house in Santa Clara. I promised my friend Matt that I would video the happy dance. I’m sure this isn’t what he was expecting, but here it is. Safe for work, family friendly, and still 100% me.

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

You can also listen on Youtube.

Next Page →


This work is licensed under a Creative Commons Attribution 3.0 United States.