Internet explorer says Object doesn't support this property or method

This line is 79:

window.addEvent('domready', function(){     
    mySlide = new Fx.Slide('advert');
    mySlide.hide();
});

It also does not like this line:

this.wrapper = new Element('div',
                           {
                              'styles': $extend(
                                                this.element.getStyles('margin'), 
                                                {'overflow': ''}
                                               )
                           })
                .injectAfter(this.element)
                .adopt(this.element);

Does anyone know why this happens? Does anyone know how to fix this? I am using jQuery and Mootools.. and wanted a solution.

Answers


In case you are landing on this page while desperately searching for why you have this error in IE, allow me to point out another way this can happen. Hopefully, either the mere act of me posting this will help me remember this, or this question will show up in google the next time I run into this error. It seems to happen at least every 2 years.

This can show up if you've named a variable (Not sure if it has to be global, mine was this time) the same thing as an element's ID. For instance:

<div id="foo">
</div>
<script type="text/javascript">
    var foo = 1; < --Object doesn 't support this property or method!!
</script>

Do you have jQuery/mooTools included before this particular line in the file? It looks to me like you've included a plugin or other javascript before including the framework that it relies on. I assume you're also using jQuery in noConflict() mode since you're using both jQuery and mooTools.


+1 for the earlier answer about variable names. This in IE8:

title = button.attr('title'); <-- Object doesnt support this method

$title = button.attr('title'); <-- OK!

This error normally comes with IE if you try to assign a invalid value for a style property. If you are using IE8 and you have enabled enable javascript debugging under tools->options->advanced, then you can try to debug it and see which property assignment is throwing this error and then try to rectify this.


This can also happen if you don't have a comma in a list of variables, like the 'f' variable below :

var a = 'aaaa',
    f = 'ffff'
    b = someObject.attribute;

Just a quick addition to the conversation.

In some cases (video.js / bigvideo.js come to mind) you need to run modernizr.js as your first script before jQuery or jQuery UI. Clears things right up.


(MooTools)

My code was something like this:

var cancel; 
//... bla bla
cancel = form.elements[i]; //cancel is now a <button>; no Id, unique on the page
cancel.addEvent('click', function(e) {...});

And I was getting the OP's exception on cancel.AddEvent(). What fixed it for me was rewriting that as $(cancel).addEvent().

What a horrible browser.


seems like you aren't really taking advantage of jQuery. I don't speak mooTools, so I may not get this completely right, but I would try something like this:

jQuery(document).ready( function() {
    //you could convert this to jQuery too, of course
    mySlide = new Fx.Slide('advert');
    mySlide.hide(); 
} );

jQuery(this).wrap( '<div class="overflow-wrapper"></div>' )
            .parent('.overflow-wrapper').css('overflow', '' );

Need Your Help

Converting ″Straight Quotes″ to “Curly Quotes”

javascript regex quotes smart-quotes

I have an application which uses a Javascript-based rules engine. I need a way to convert regular straight quotes into curly (or smart) quotes. It’d be easy to just do a string.replace for ["], o...

android compass seems unreliable

android compass-geolocation sensor android-sensors

I have been working on a small compass app the past couple of days, and have gotten the code up and running, but it seems that the compass reading is not accurate. After calibrating both phones, my...