admin管理员组

文章数量:1180493

I have code that works fine in Firefox and Chrome but not in IE 11. I'm getting next error messages:

   1) SCRIPT5009: '$' is undefined
    For this line of code:
    $.extend({ 
      )} 

   2)SCRIPT5009: 'jQuery' is undefined
         // Browser globals
            factory( jQuery );

   3)SCRIPT1010: Expected identifier
        .catch( function( error ) {
            jQuery.readyException( error );
        } );

Here is my header tag with all includes:

<head>
    <script type="text/javascript" src="jquery/jquery-3.1.1.js"></script>
    <script type="text/javascript" src="jquery/jquery-ui.js"></script>
    <script type="text/javascript" src="jquery/JQuery_alert.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="jquery/jquery-ui.structure.css">
    <link rel="stylesheet" type="text/css" href="jquery/jquery-ui.theme.css">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

I found that if I open my dev tools in IE and then in the upper right corner click on the Document mode and switch to Edge my code with all the includes above works fine. So my question is what is Edge? How I can make sure that someone else using IE will not have the problems running my page? Is there the way to fix that? Thanks in advance.

I have code that works fine in Firefox and Chrome but not in IE 11. I'm getting next error messages:

   1) SCRIPT5009: '$' is undefined
    For this line of code:
    $.extend({ 
      )} 

   2)SCRIPT5009: 'jQuery' is undefined
         // Browser globals
            factory( jQuery );

   3)SCRIPT1010: Expected identifier
        .catch( function( error ) {
            jQuery.readyException( error );
        } );

Here is my header tag with all includes:

<head>
    <script type="text/javascript" src="jquery/jquery-3.1.1.js"></script>
    <script type="text/javascript" src="jquery/jquery-ui.js"></script>
    <script type="text/javascript" src="jquery/JQuery_alert.js"></script>
    <link rel="stylesheet" type="text/css" href="jquery/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="jquery/jquery-ui.structure.css">
    <link rel="stylesheet" type="text/css" href="jquery/jquery-ui.theme.css">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

I found that if I open my dev tools in IE and then in the upper right corner click on the Document mode and switch to Edge my code with all the includes above works fine. So my question is what is Edge? How I can make sure that someone else using IE will not have the problems running my page? Is there the way to fix that? Thanks in advance.

Share Improve this question edited Oct 21, 2016 at 16:28 espresso_coffee asked Oct 21, 2016 at 14:09 espresso_coffeeespresso_coffee 6,11012 gold badges93 silver badges219 bronze badges 7
  • Is this site running locally or did you deploy it somewhere to test? I've had issues with IE 11 and the default behavior of "display intranet sites in compatibility mode" checkbox – Matti Price Commented Oct 21, 2016 at 14:13
  • This is running on my test site, my code files and JQuery files are in the same directory. How and where I have to check compatibility mode and how to set Edge? – espresso_coffee Commented Oct 21, 2016 at 14:17
  • 1 If the site's in development you can append <meta http-equiv="X-UA-Compatible" content="IE=edge" /> to the <head> element which will coerce IE to run in Edge mode instead of IE8. – psdpainter Commented Oct 21, 2016 at 14:18
  • 1 In addition to compatibility mode, there is also quirks mode, which is even worse (it emulates IE5, and jQuery definitely will not work with it). To prevent Quirks Mode, make sure your HTML starts with a valid doctype. If you haven't done this already, the easiest way is to make this the first line of your HTML: <!DOCTYPE html> – Simba Commented Oct 21, 2016 at 14:21
  • I unchecked compatibility view and tried to include the meta tag for IE edge but still getting an error for every line of JQUery code. I'm not sure what else can cause this error... – espresso_coffee Commented Oct 21, 2016 at 15:28
 |  Show 2 more comments

2 Answers 2

Reset to default 32

Compatibility View

When Internet Explorer runs in compatibility view, it emulates older versions such as IE8 which is incompatible with the latest version of jQuery (only the 1.x versions of jQuery are compatible with older versions of IE).

Checking if Compatibility View is the Problem

When you hit F12 in Internet Explorer, it should bring up the Developer Tools. Near the top right of the toolbar, you should find a drop down that lets you switch between Edge, 10, 9, 8, 7, and 5. Switching it will cause the page to refresh using the new document mode. If you switch to Edge and you still get the jQuery errors, then you can rule out compatibility view as the problem.

Making sure the page won't be displayed in Compatibility View

Check the documentation here regarding specifying document modes for Internet Explorer: https://msdn.microsoft.com/en-US/library/jj676915.aspx

You can also try to force IE11 to display in Edge mode by inserting a <meta> tag into the Header of your HTML (it should be the first tag within the Header) like so:

<html>
<head>
    <meta http-equiv="x-ua-compatible" content="IE=edge">
...

This instructs Internet Explorer to explicitly use that document mode.

You can also experience issues if your jquery references are stored in a .jspf file that is referenced as an include. IBM Websphere will cache the jspf's in a temp folder on the server and they will not be replaced even with a ear/war deploy. It is necessary to remove those files from the temp folder.

本文标签: javascriptIE11 JQuery errorStack Overflow