简体   繁体   中英

jQuery not working in IE, works in other browsers

Currently coding a mates portfolio and not to my surprise the code isn't loading in IE!

I'm coding it using standard AJAX, here's the relevant jQuery:

//ajax shtuff

$(window).load(function() {

    // Ajax Cache!
    $.ajaxSetup ({  
        cache: false  
    });

    var $loadW = '<div id="whiteLoader" />';
    var $loadurl = $('.current').attr('href');

    // Initial Page Load
    $('#con').prepend($loadW);
    $('#main').fadeOut('slow', function() {
        $(this).load($loadurl + ' .page', function() {
            $(this).parent().find('#whiteLoader').fadeOut('slow', function() {
                $(this).parent().find('#main').fadeIn('slow').css({background: 'red'});
                $(this).remove();
            });
        });
    });

    $('nav ul li a').each(function() {
        $(this).click(function(e) {

            var $loadW = '<div id="whiteLoader" />';
            var $loadurl = $(this).attr('href');

            // Prevent default hotlink
            e.preventDefault();

            // Add the current state
            $('*').removeClass('current');
            $(this).addClass('current');

            // Load the Page
            $('#main').fadeOut('slow', function() {
                $('#con').prepend($loadW);
                $('#main').load($loadurl + ' #main', function() {
                    $('#whiteLoader').fadeOut('slow', function() {
                        $('#main').fadeIn('slow');
                        $(this).remove();
                    });
                });
            });

        });
    });

});

Literally have no idea why this doesnt work lol, here's a link to the live page (I've put the background as red just to show you the area.)

Also the reason the initial page is using the 'this' method is because I was testing it both ways.

http://212.7.200.35/~tfbox/zee/

have you tried

$(document).ready(function() {
    // Stuff to do as soon as the DOM is ready;
});

instead of window.load?

Often IE has trouble styling / selecting any of the new HTML5 elements such as section and nav . Try using something like this or simply using a div

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM