简体   繁体   English

IE9中的Bootstrap下拉菜单不起作用

[英]Bootstrap drop down menu in IE9 is not working

I would like to create a drop down menu on rails 3.2.8 using bootstrap twitter. 我想使用bootstrap twitter在rails 3.2.8上创建一个下拉菜单。 The drop down works in Firefox but would not open in IE9. 该下拉列表可在Firefox中使用,但无法在IE9中打开。 Here is the code that I have so far: 这是我到目前为止的代码:

<!DOCTYPE HTML>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript" src="https://raw.github.com/twitter/bootstrap/master/js/bootstrap-
dropdown.js"></script>

<%= stylesheet_link_tag "application", media: "all"%>
<%= javascript_include_tag%>
<%= csrf_meta_tags %>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar .navbar-fixed-top">
<div class="nav-collapse">
<div class="navbar-inner">
    <div class="container">
        <a class="brand" href="#">
            Home
        </a>
        <ul class="nav">
            <li class="dropdown" id="fat-menu">
                <a href="#fat-menu" class="dropdown-toggle" data-toggle="dropdown">
                    Drop-Down Menu
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a>SAve</a></li>
                    <li class="divider"></li>
                    <li><a>Print</a></li>
                </ul>
            </li>
        </ul>
    </div>
</div>
</div>
</div>
<script>$(function() {$('.dropdown-toggle').dropdown()});</script>       
<div class="container">
  <%= yield %>
</div>
</body>
</html>

Please is there something that I need to do to fix the issue on the IE9? 请问我需要做些什么来解决IE9上的问题? Thanks 谢谢

You can't use https://raw.github.com/twitter/bootstrap/master/js/bootstrap-dropdown.js because the MIMETYPE is text/plain and apparently IE9 will reject that. 您不能使用https://raw.github.com/twitter/bootstrap/master/js/bootstrap-dropdown.js,因为MIMETYPE是text / plain,显然IE9会拒绝它。

Just download the resource and serve it locally or find a valid cdn. 只需下载资源并在本地提供服务或找到有效的CDN。


For example: http://jsfiddle.net/2D7wD/1/ 例如: http : //jsfiddle.net/2D7wD/1/

using: <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script> 使用: <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>

You don't need the data-toggle attribute and a Javascript call, the script will look for the data-toggle and instantiate the plugin for you. 您不需要data-toggle属性 Javascript调用,该脚本将查找data-toggle并为您实例化插件。

Try removing one or the other. 尝试删除其中一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM