1

I am getting an error in IE8: Object doesn't support this property or method yet everything works in the other browsers no problem. When IE is refreshed the error goes away and the slideshow displays properly.

Here is the code.

$(window).load(function(){
  $('.flexslider').flexslider({
    animation: "slide",
    start: function(slider){
      $('body').removeClass('loading');
    }
  });
});

The line causing the error is $('.flexslider').flexslider({

I've tried various solutions to no avail. Any suggestions?

BryanH
  • 5,826
  • 3
  • 34
  • 47
J Ward
  • 21
  • 1
  • 3

2 Answers2

1

Found the answer and it wasn't in the line of code I posted. I was using

<script defer src="scripts/jquery.flexslider.js"></script>

to load the script and I changed it to

<script src="scripts/jquery.flexslider.js"></script>

Everything works fine now.

J Ward
  • 21
  • 1
  • 3
0
$(function() {
    $(window).load(function() {
        $('.flexslider').flexslider({
          animation: "slide",
          start: function(slider){
          $('body').removeClass('loading');
         }
    });
});

This makes use of jQuery.ready(), which is more reliable than $(window).load() cross-browser.

In fact, you can replace $(window).load() altogether (if you don't need to wait for images or etc).

$(function() {
    $('.flexslider').flexslider({
        animation: "slide",
        start: function(slider){
        $('body').removeClass('loading')
    }
});

Also, make sure the script that includes the flexslider is included in the "head" section of your page. If you include it in the body or load it by creating a DOM node, neither load nor ready will guarantee that it has been executed.

Joe Enzminger
  • 11,110
  • 3
  • 50
  • 75
  • 1
    But why did you still leave that `$(window).load()` there? :) – kapa Dec 20 '12 at 23:49
  • Maybe the `window.load` is required to make sure all images are loaded before the code is initialized. Either way, it does not hurt anything to have it there. – Sparky Dec 20 '12 at 23:50
  • Good point...your comment came as I was editing the answer :) – Joe Enzminger Dec 20 '12 at 23:50
  • Actually, Sparky is right - ready does not mean window.load. See [this question](http://stackoverflow.com/questions/6587939/what-exactly-does-document-ready-guarantee). If you need to wait for resources (images, etc), then you have to also include window.load. – Joe Enzminger Dec 20 '12 at 23:55
  • Have tried all of the suggestions. Even moved code around and still displays an error only in IE8. Works fine in all other browsers. In IE8 if you navigate off the page then go back everything works fine with no errors. Strange, I am assuming something isn't loading in the proper order but can't figure it out. – J Ward Dec 26 '12 at 13:50