wilsonrufus
wilsonrufus

Reputation: 449

javascript IE 8 bug

I keep on getting this particular error in the code

Object doesn't support this action

What does this mean "Object doesn't support this action" ???

attachEvent = function(state){
                if(state == 'up'){
                    slideUp();
                    return false;
                }
                if(state == 'down'){
                    slideDown();
                    return false;
                }
                $(up).click(function(){
                    slideUp();
                });
                $(down).click(function(){
                    slideDown();
                });
            }

Upvotes: 0

Views: 84

Answers (1)

Tim Down
Tim Down

Reputation: 324497

Without using var, your code will attempt to assign a value to a property called attachEvent in the global object. The global object is window in browsers, so this attempted assignment fails in IE because there is a pre-existing, read-only window.attachEvent method.

The easiest fix is to use var:

var attachEvent = function(state) {
    // Stuff
};

Upvotes: 1

Related Questions