为什么IE11上有奇怪的行为?

时间:2014-09-11 06:44:11

标签: jquery html css asp.net-mvc jquery-mobile

我的部署版本的jQuery Mobile网站似乎存在问题。在本地机器上运行,看起来不错。

然而,当部署到测试服务器时,jQuery Mobile的ui遇到了问题(如下图所示)。我已经在IE11和Chrome上测试了部署的网页。在Chrome上,它看起来与本地托管版本完全相同,所以它只是"奇怪的"我在IE11上。

enter image description here

HTML源代码在两个版本上当然都是相同的,除了文件的路径(css / js)之外,但在Chrome上它同样适用于两个版本'。

<!DOCTYPE html>
<html>
<head>
  <title></title>
  <meta name="viewport" content="width=device-width" initial-scale="1" />
  <!-- Styles -->
  <link href="/Content/Site.css" rel="stylesheet" type="text/css"/>
  <link href="/Content/jquery.mobile-1.4.2.css" rel="stylesheet" type="text/css"/>
  <link href="/Content/jquery.mobile.datepicker.css" rel="stylesheet" type="text/css"/>
  <!-- Scripts -->
  <script src="/Scripts/Bundles/jquery?v=_evuqQpQzfiv74i_e2xne0q8qDFolKEd-XnaMgC-rWw1"></script>

  <script src="/Scripts/jquery.ui.datepicker-nb-NO.js"></script>
  <script src="/Scripts/Bundles/jqueryMobile?v=sCRDQK2ukYmfF8e6gB7crpqBhGj3REAZ0OWnxCy4ozU1"></script>

</head>
<body>
  <div data-role="page" data-theme="a">
    <div data-role="header" data-theme="a">
      <a href="/" data-icon="home" data-iconpos="notext">Home</a>

      <h1></h1>
    </div>
    <div data-role="content">

<a href='#' data-role="button"><div><div class="btn-icon-text">Button 1</div></div></a>
<a href='#' data-role="button"><div><div class="btn-icon-text">Button 2</div></div></a>

    </div>
    <div data-role="footer" data-position="fixed" data-theme="a">
      <div id="leftBottomContent" style="float: left"><a href="#" data-rel="back" class="ui-btn">back</a></div>
      <div id="rightBottomContent" style="float: right"></div>
      <div id="centerBottomContent" style="margin-left: auto; margin-right: auto; text-align: center; margin-top: 15px;"></div>
    </div>
  </div>
</body>
</html>

我已经使用Fiddler检查过来自服务器的请求是否正常。任何人都可以指出我的方向来解决这个问题吗?

3 个答案:

答案 0 :(得分:2)

因此,在您自己的PC上设置兼容模式可以解决您的问题,但是对于试图使用您的应用程序的其他人来说该怎么样?

您可以在布局中添加meta标题,这会强制执行兼容模式,从而使其他人不会遇到与您相同的问题

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

请务必在html

中的<head>标记后立即添加此内容

答案 1 :(得分:0)

关闭Intranet站点上的兼容模式解决了我的问题

答案 2 :(得分:0)

将以下代码添加到标题页,这使得用户在使用应用程序时默认使用兼容模式:

    <%
    response.addHeader("X-UA-Compatible", "IE=edge");
    %>