JQuery没有在ASP.NET MVC4项目中的IE生产中运行

时间:2013-10-11 14:04:12

标签: jquery asp.net asp.net-mvc internet-explorer

我很困惑。我有一个非常简单的菜单,在mouseentermouseleave jquery使用slideDownslideUp来显示子菜单。

它适用于从Visual Studio运行的所有浏览器(包括IE)。当我将它推送到我们的IIS服务器时,它在所有浏览器上工作正常,除了IE(在IE10和IE11上测试),这真的让我感到困惑。

这是我的_Layout中的简单jquery:

<script>
    $('li.liSlide').mouseenter(function () {
        $(this).children().next().slideDown();
    })
    $('li.liSlide').mouseleave(function() {
        $(this).children().next().slideUp();
    });
</script>    

示例子菜单:

<li class="liSlide">
    <a href="#">Batch</a>
    <ul>
         <li>@Html.ActionLink(((controller == "BatchSummary") ? "▷ " : "") + "Batch Summary", "BatchSummary", "BatchSummary")</li>
     </ul>
</li>

我尝试设置警报并更新一些css以测试IE是否进入这些功能,但事实并非如此。有谁知道我应该在哪里开始调试这个?我也可以发布更多相关代码。

1 个答案:

答案 0 :(得分:0)

本网站上的另一个问题:

So for anyone out there who might run into the same issue and has to work with IE I solved the problem by adding this to my _layout.cshtml:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

What this does is instructs IE to use the latest available rendering engine to process the html (in other words don't try to be smart and guess what my html is built for). So it essentially tells the versions of IE that have 'compatibility mode' to not use it.

For me this works fine because our organization is small and we are usually within one version of the latest release of IE. If the latest version causes issues, I can easy fix and deploy with no harm done. However, this IS NOT optimal for a general purpose website or organization with high numbers of users on a variety of IE browsers.

这为我修好了。