Ok, so finally the medixbox menus are coming together, they slide up, slide down, show the right state and all the other nitty gritty associated with prettiness. Quick launch IE tester. KAbbooom!!!(‘background-position’) is undefined” or some other useful crap is spouted forth.

Now I am in love with JQuery, like everyone else. I’ve had my fair share of JavaScript woes over the years and using JQuery is like putting lipstick on a pig and actually looking nice.

Several coffees and expletives later it turns out Internet Explorer  in all its reincarnations doesn’t seem to know what “background-position” is and instead retrieves its own “background-position-x” and “background-position-y” css rule. That’s all very nice and good but it means my code now has to have this:

function determine_x_pos(obj){
//parameter obj is something like $('#my-div')
    var pos = $(obj).css("background-position");
    if (pos == 'undefined' || pos == null) {
        pos = $(obj).css("background-position-x"); //die in hell
    } else {
        pos = pos.split(" ")[0];
    }
    return pos  || 0; //yes returning a 0 on fail  is bad but its for demo!
}

In true NastyHabit fashion, the code is shit. Nevertheless, it works a treat!

The paranoid guy in me believes this cursed issue only afflicts me. Please check if you too have been burdened by the beast of redmond and help a fellow man feel less picked on by the curse of IE.


  1. I’ve been bitten by this too and I’ve only been learning jQuery for a few days. Did you ever get a satisfactory fix? IMO this is something that a) should be fixed by the browser manufacturer and b) until then abstracted away in a framework. Still not fixed in IE8 either…

  2. hi there,

    i had more success with this:

    if ($(this).css(‘background-position-x’)) {
    var pos = parseInt($(this).css(‘background-position-x’).split(‘ ‘)[0]);
    } else {
    var pos = parseInt($(this).css(‘background-position’).split(‘ ‘)[0]);
    };

  3. The Man

    Hi Christof thanks for that looks like a much simpler solution. I see its 2009 and we’re still talking about this issue!

  1. 1 graham.reeds/ » So where is the background?

    [...] is a whole raft of information on the Net about this very issue and I’ve ran into it after a couple of weeks but amazingly no one has offered a [...]




Leave a Comment