开发者

Javascript not loading in IE7

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/javas开发者_JS百科cript"></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>


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.


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);


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'
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜