【问题标题】:Is there a way to control the title for a Content-type: text/plain document?有没有办法控制 Content-type: text/plain 文档的标题?
【发布时间】:2016-08-30 16:29:03
【问题描述】:

在 Content-type: text/plain 文档中,有什么方法可以控制文档的页面标题(即 Web 浏览器标题栏中显示的标题)?

显然没有办法从内容上控制这一点,但基本上相当于HTML中<title>标签的效果。

我希望有一个类似于Content-type: text/plain 的 HTTP 服务器响应来控制可能影响标题的内容标题。例如Content-Description: 甚至是 X- 命令,可能是特定于浏览器的。我希望是Content-Title: (我不认为它不存在)

【问题讨论】:

  • 我也有这个问题。

标签: http http-headers content-type


【解决方案1】:

这个问题已经 5 年没有答案了,所以我能做的最好的事情就是创建一个带有标题的 html 页面,并让它只包含一个加载 .txt 文件的全屏 <iframe>

这似乎适用于 chrome 和 firefox,所以除非出现更好的东西,否则我将继续使用它......

<!DOCTYPE html>
<html>
<head>
  <title>HTML Title</title>
  <style>
      body { margin: 0; }
      iframe { border: 0; width: 100%; height: 100%; position: fixed; }
  </style>
</head>
<body>
    <iframe src="foo.txt"></iframe>
</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-01
    • 2012-05-19
    • 2016-01-23
    • 1970-01-01
    • 2011-04-22
    • 2013-06-09
    • 2013-01-19
    • 2010-12-10
    相关资源
    最近更新 更多