views:

218

answers:

3

Hello,

I'm having trouble getting JQuery to load in IE7, works fine in all other browsers, firefox,safari,opera,ie8 just not in IE7.

If anybody has any sort of idea why, please do let me know.

Many Thanks,

Q

This is before the

<script  src="js/jquery.js" type="text/javascript"></script>
<script  src="js/plugins.js" type="text/javascript"></script>

<script type="text/javascript">
$(function(){
$('#coda-slider-1').codaSlider();
    $('#coda-services-1').codaSlider();
        $('#coda-work-1').codaSlider();

$("a[rel=rab]").fancybox({
                'transitionIn'  : 'fade',
                'transitionOut' : 'fade',
                        'titlePosition'     : 'over',
            });
$("a[rel=annsummers]").fancybox({
                'transitionIn'  : 'fade',
                'transitionOut' : 'fade',
                        'titlePosition'     : 'over',
            });
$("a[rel=sportingbet]").fancybox({
        'transitionIn'      : 'fade',
        'transitionOut'     : 'fade',
                'titlePosition'     : 'over',
    });
$("a[rel=ryman]").fancybox({
        'transitionIn'      : 'fade',
        'transitionOut'     : 'fade',
        'titlePosition'     : 'over',
    });
$('a').click(function() {
   var elementClicked = $(this).attr("href");
   var destination = $(elementClicked).offset().top;
   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 1000 );
   return false;
    });
});

 function formatText(index, panel) {
          return index + "";
        }    
        $(function () {
            $('.slider').slider({
                easing: "easeInOutQuart", 
                autoPlay: true, 
                delay: 3300,   
                startStopped: false, 
                animationTime: 900, 
                hashTags: false, 
                buildNavigation: true,
                pauseOnHover: true,  
                navigationFormatter: formatText   
            });
        $("#slide-jump").click(function(){
                $('.slider').slider(6);
            });    
        });
 function formatText(index, panel) {
          return index + "";
        }    
        $(function () {
            $('.history-slider').slider({
                easing: "easeInOutQuart", 
                autoPlay: false,    
                delay: 3000,    
                startStopped: false,        
                animationTime: 900,         
                hashTags: false,       
                buildNavigation: false,   
                pauseOnHover: true,      
                navigationFormatter: formatText       
            });
        $("#slide-jump").click(function(){
                $('.history-slider').slider(6);
            });    
        });

</script>
+10  A: 

The problem is the trailing commas; IE doesn't like those. Here's one, for example:

$("a[rel=rab]").fancybox({
    'transitionIn'  : 'fade',
    'transitionOut' : 'fade',
    'titlePosition' : 'over',  // <= the trailing comma
});

It doesn't like them in array initializers either.

T.J. Crowder
+1. Yeah, this means you have to be extra vigilant with copy/paste operations when working with array or object literals. Make sure the last element doesn't contain the comma or you have yourself a syntax error in IE.
Andy E
This is the issue. Happens to me a lot and it drives me crazy because it can be so difficult to find.
Josh
A: 

You could save yourself a bunch of typing by just declaring that parameter block once:

var fancyboxSetup = {
  'transitionIn'  : 'fade',
  'transitionOut' : 'fade',
  'titlePosition'     : 'over'
};

then just use it by name:

$("a[rel=rab]").fancybox(fancyboxSetup);

You might also find that you can set up all your anchors with one call:

$('a[rel]').fancybox(fancyboxSetup);
Pointy
A: 

I think it's because of the extra commas in the property listing.

$("a[rel=sportingbet]").fancybox({
        'transitionIn'      : 'fade',
        'transitionOut'     : 'fade',
                'titlePosition'     : 'over', <---------
    });

Also, you may be able to combine all the items into one selector to save on file size. I don't know if you need the flexibility for the transistions though.

$("a[rel=annsummers], a[rel=sportingbet], a[rel=sportingbet], a[rel=ryman]").fancybox({
        'transitionIn'      : 'fade',
        'transitionOut'     : 'fade',
                'titlePosition'     : 'over'
    });
easement