Jquery not loading properly in ie

2019-08-07 19:48发布

问题:

I have a WIP portfolio site here:

http://benliger.webatu.com/

I have a few events running jquery in order to change page which seems to work fine in firefox and chrome. The strange thing is when I try it in IE 11, the change page function does not work. Upon inspecting element I got a message saying

"SCRIPT438: Object doesn't support property or method 'easeInBack' jquery.min.js, line 2 character 87746"

When I trace the error in the jquery file it says that the file route folder is ajax.googleapis.com/ajax/libs/jquery/1.8.3 which doesn't sound right as I have not referenced this URL anywhere in my code and I imagine my change page function (found in changepage.js) is not working as its running of this older version of jquery.

If someone could please explain to me whats going on here that would be great, also how to fix it :)

回答1:

Looking in your link, you can see that the host company is adding their own Analytics, which includes the jQuery v1.8.3 library automatically:

<script src="http://stats.hosting24.com/count.php" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://stats.hosting24.com/popup/popup.js"></script>
<style type="text/css" media="screen"></style>
<script type="text/javascript"></script>
<!-- End Of Analytics Code -->
<div class="bModal __bPopup1" style="left: 0px; top: 0px; width: 100%; height: 100%; position: fixed; z-index: 9998; cursor: pointer; opacity: 0.7; background-color: rgb(0, 0, 0);"></div>
<div class="popup" id="visas_style_div" style="left: 350px; top: 49.5px; position: absolute; z-index: 9999;"></div>
</body>
</html>
<!-- Hosting24 Analytics Code -->

You can run this bit of script in your page to remove this library:

$(function () {
    $('script[src*="1.8.3"]').remove();
});

Try adding it to your page head, and if it doesn't work, place it immediately before you close the body.

Demo

If you can't manage to remove the old library, you can always work out conflicts:

// Managing the jQuery conflicts.
jQuery.noConflict();
(function ($) {
    // A single document ready event handler.
    $(function () {

        // All your script goes here...

    });
})(jQuery);

Demo

jQuery.noConflict()

This will make sure that your scripts will be looking for the library you've chosen to work with, and not that old one.