IE11 jQuery错误? [英] IE11 JQuery error?

查看:313
本文介绍了IE11 jQuery错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码可以在Firefox和Chrome中正常运行,但不能在IE 11中运行.我收到下一条错误消息:

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>

我发现,如果我在IE中打开我的开发工具,然后在右上角单击文档"模式,然后切换到边缘",则上面所有包含的代码都可以正常工作.所以我的问题是什么是Edge?如何确保使用IE的其他人不会在运行我的页面时遇到问题?有办法解决吗?提前致谢.

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.

推荐答案

兼容性视图

当Internet Explorer在兼容性视图中运行时,它会模拟较旧的版本,例如IE8,该版本与jQuery的最新版本不兼容(仅jQuery的1.x版本与IE的较早版本兼容).

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

检查兼容性视图是否存在问题

当您在Internet Explorer中按F12键时,它应该会显示开发人员工具.在工具栏的右上角附近,您会找到一个下拉菜单,可让您在Edge,10、9、8、7和5之间进行切换.对其进行切换将使页面使用新的文档模式进行刷新.如果切换到Edge仍然出现jQuery错误,则可以排除兼容性视图作为问题.

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.

确保该页面不会显示在兼容性视图"中

在此处查看有关为Internet Explorer指定文档模式的文档: https://msdn.microsoft.com/zh-CN/library/jj676915.aspx

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

您还可以尝试通过将<meta>标记插入HTML的页眉(它应该是页眉中的第一个标签)来强制IE11在Edge模式下显示:

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">
...

这指示Internet Explorer显式使用该文档模式.

This instructs Internet Explorer to explicitly use that document mode.

这篇关于IE11 jQuery错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆