简体   繁体   中英

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. The drop down works in Firefox but would not open in 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? 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.

Just download the resource and serve it locally or find a valid cdn.


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

using: <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.

Try removing one or the other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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