有没有办法控制 Content-type: text/plain 文档的标题?

erc*_*rco 6 content-type http http-headers

在 Content-type: text/plain 文档中,有没有办法控制文档的页面标题(即浏览器标题栏显示的标题)?

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

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

erc*_*rco 1

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

这似乎适用于 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>
Run Code Online (Sandbox Code Playgroud)