views:

235

answers:

2

Hi,

I'm using prototype and setStyle in IE6 is just messing everything up. It's throwing a big error.

I've Googled it but cant find a solution.

I've identified the line in prototype with the IE script debugger, it's the final else block:

setStyle: function(element, styles) {
    element = $(element);
    var elementStyle = element.style, match;
    if (Object.isString(styles)) {
      element.style.cssText += ';' + styles;
      return styles.include('opacity') ?
        element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
    }
    for (var property in styles)
      if (property == 'opacity') element.setOpacity(styles[property]);
      else
        elementStyle[(property == 'float' || property == 'cssFloat') ?
          (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
            property] = styles[property];

    return element;
  },

Anyone had this problem?

P.S. normally I would use jQuery however this is someone else code I've had to update.

+1  A: 

Aaand what version of Prototype.js is used?

npup
cheers, updated it too the current one and it worked.
Smickie
Out of curiosity, which version were you using?
npup
A: 

I just ran into this problem myself... if you are using the IE debugger, find the option to show the stack and back up until you get into your own code. The likely culprit is a bogus style setting. In my case I had a copy/paste problem and was attempting to do this:

msgDiv.setStyle( { padding: '6px', margin: 'margin' } );

this line

msgDiv.setStyle( { padding: '6px', margin: '4px' } );

worked perfectly...

Jim Benson