导入javascript库适用于chrome但不适用于IE

时间:2015-09-01 09:42:24

标签: javascript jquery asp.net-mvc google-chrome internet-explorer

我正在使用ASP.NET MVC 5,我正在尝试将一些javascript库导入为jquery,bootstrap.js等等。它在Chrome中运行良好,但在IE 11中运行良好。

有人能看到我错过的东西吗?

BundleConfig:

public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-2.1.4.js",
                    "~/Scripts/jquery-2.1.4.min.js",
                    "~/Scripts/EventReader.js",
                    "~/Scripts/jquery.floatThead.js",
                    "~/Scripts/jquery.floatThead.min.js",
                    "~/Scripts/jquery.unobtrusive-ajax.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/bootstrap.min.css",
                  "~/Content/EventReader.css"));
    }

_layout:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Styles.Render("~/Content/bootstrap")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")


</head>
<body>
<div class="container body-content">
@RenderBody()
@RenderSection("scripts", required: false)
</div>

</body>
</html>

我的观点(索引):

@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<html>
<head>
<meta name="viewport" content="width=device-width"/>
<title>Index</title>

</head>
<body>
</body>

在IE11中,我得到以下错误:

Object doesn't support property or method 'addEventListener' (jquery-2.1.4.js).
Object doesn't support property or method 'addEventListener' (jquery-2.1.4.min.js)
Bootstrap's JavaScript requires jQuery (bootstrap.js)

1 个答案:

答案 0 :(得分:1)

添加 文档主管部分中的<meta http-equiv="X-UA-Compatible" content="IE=Edge"> 强制IE使用最新的IE版本标准进行渲染。