gpt4 book ai didi

ruby-on-rails - (Ruby on Rails) 页面标题以文本/javascript 的形式出现,当它不应该的时候

转载 作者:行者123 更新时间:2023-12-04 03:43:00 26 4
gpt4 key购买 nike

我正在开发一个 Rails 应用程序,但在使用 Internet Explorer 访问它时发现了一个问题。Firefox 和 Safari 可以正常显示页面。一直以来,在使用 Internet Explorer 时,在某些页面中,它会尝试下载页面,而不是显示页面。我不知道会发生什么。

这是我的 application.html.erb 的 html header :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="otzee_header_scripts">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test site</title>
<meta name="robots" content="index, follow" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="NZN - No Zebra Network" />
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<%= stylesheet_link_tag "default.css" %>
<%= stylesheet_link_tag "#{site_theme}/default", :id => 'theme_change_css' %>
<%= stylesheet_link_tag "#{site_theme}/toyart.css", :id => 'theme_change_bg_css' %>

<!-- Includes Globais -->
<%= javascript_include_tag 'jquery' %>
<%= javascript_include_tag 'jquery-ui' %>
<%= javascript_include_tag 'jrails' %>
<%= javascript_include_tag 'games' %>
<%= javascript_include_tag 'users' %>
<%= javascript_include_tag 'application' %>
<%= stylesheet_link_tag 'application' %>
<%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>

<%= yield(:head) %>
<!-- Globais -->

<!--[if lte IE 6]>
<link href="stylesheets/ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<script src="http://www.google.com/jsapi"></script>

</head>

但是我觉得和application.html.erb没有关系,因为有的页面显示正常,有的是ie下载的。

是否知道可能导致此问题的原因?或者如何解决?

提前致谢

更新

我现在知道这与 header 有关,它作为 mime 内容类型文本/javascript 而不是文本/html 发送。但我不知道为什么。这是 Controller 代码,如果有人指出我的错误,请。

def index
respond_to do |format|
format.js do
if params[:bookmarks] != 0
@games_infos = current_user.games_info_bookmarks params[:page], 8
@bookmarks = 1
else
@games_infos = current_user.games_info_collection params[:page], false, 8
@bookmarks = 0
end
end
format.html do
@invites = current_user.friends_pending
@whats_new = WhatsNew.find_user_network_updates @me, 1, 13
@games_infos = @me.games_info_bookmarks params[:page], 8
@bookmarks = @games_infos.size
@games_infos = @me.games_info_collection(params[:page], false, 8) unless @bookmarks > 0
@friends = @me.friends_on_off
@high_scores = @me.high_scores
end
end
end

Obs:firebug 显示 Content-Type text/html; charset=utf-8 在 firefox 上,Fiddler 显示 Content-Type text/javascript; charset=utf-8 在 Internet Explorer 上。

最佳答案

我总是把 format.html 放在第一位。这样,当 IE 发送一个奇怪的接受 header 时,如“/”,它将呈现它命中的第一个。在你的情况下,IE 说它正在寻找任何东西,所以你发送它 js。把你的 format.html block 放在第一位,你就会成功。

(有关更多详细信息,请参阅 my answer here)

关于ruby-on-rails - (Ruby on Rails) 页面标题以文本/javascript 的形式出现,当它不应该的时候,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1897099/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com