网站无法在所有浏览器上运行

时间:2013-03-05 06:53:34

标签: ruby-on-rails ruby-on-rails-3 internet-explorer twitter-bootstrap

我的网站在我的Mac和iPhone上运行良好,但在IE浏览器中却没有。在IE中,一些导航栏功能不正确(即布局不正确,搜索框没有占位符文本,其中一个导航栏元素(收藏夹)看起来完全不同)。我不确定问题出在哪里

layout / application.html.erb是

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <%= analytics_init if Rails.env.production? %>
  <title>Guidelines for Me</title>

  <%= stylesheet_link_tag    "application", :media => "all" %>

  <%= javascript_include_tag "application" %>
  <link href="../assets/bootstrap-responsive.css" rel="stylesheet">
  <%= csrf_meta_tags %>

  <script type="text/javascript">
function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}
function clearText(){
    search = $('.search-query');
    if (search.defaultValue==search.value)
    search.value = ""
}
type="text/javascript">
$(document).ready(function() {
    $('.collapse').collapse();
}); 


</script>
</head>
<body>

    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container">
                <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                </a>

                <% if Guideline.count % 100 ==0 %>
                    <%= link_to "#{Guideline.count}" " guidelinesforme - yay!", guidelines_path, :class => 'brand' %>
                <% else %>

                    <%= link_to "#{Guideline.count}" " guidelinesforme!", guidelines_path, :class => 'brand' %>
                <% end %>



            <div class="nav-collapse in collapse">
                <ul class="nav">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        List by...
                        <b class="caret"></b>
                        </a>


                    <ul class="dropdown-menu">
                        <li><%= link_to "...Topic", topics_path %></li>
                        <li><%= link_to "...Organisation", hospitals_path %></li>
                        <li><%= link_to "...Specialty", specialties_path %></li>
                        </li>   
                    </ul>

                    <% if user_signed_in? %>
                        <li><%= link_to "Favourites", favourites_path %></li>
                    <% else %>  
                        <li><%= link_to "Favourites", register_path %></li>
                    <% end %>
                </ul>

                <ul class="nav pull-right">
                <li class="dropdown">
                     <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    <% if user_signed_in? %>
                        <%= current_user.first_name %>
                    <% else %>
                        Log in or Sign up
                    <% end %>
                    <b class="caret"></b>
                    </a>


                <ul class="dropdown-menu">

                    <% if user_signed_in? %>
                        <li ><%= link_to "Edit profile", edit_path %></li>
                        <li> <%= link_to "Log out", logout_path %></li>
                    <% else %>
                        <li><%= link_to "Log in", login_path %></li>
                        <li><%= link_to "Sign Up", register_path %></li>
                    <% end %>

                    <li><%= link_to "About us", about_path %></li>
                    </li>
                </ul>

                </li>




                    <li >
                    <%= form_tag guidelines_path, :class => 'navbar-search', :onSubmit=>"clearText(this)",:method => :get do %>  

                    <%= text_field_tag :search, params[:search], :class => 'search-query input-small', :placeholder=>"Search", :ONFOCUS=>"clearDefault(this)" %> <% end %>
                    </li>

                </ul>
            </div>
            </div>
        </div>
    </div>

    <div class="container">

        <% flash.each do |type, message| %>

            <div class="alert <%= flash_class type %>">
                <button class="close" data-dismiss="alert">x</button>
                <%= message %>
            </div>
        <% end %>
    </div>

    <div class="container"> 
        <%= yield %>
    </div>


</body>

</html>

我使用过twitter bootstrap。

我确实添加了

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

在我之前,但它似乎没有什么区别。

1 个答案:

答案 0 :(得分:0)

首先,IE9不支持占位符。但是您可以使用javascript pollyfills来启用占位符支持,为此目的使用http://www.modernizr.com/