【问题标题】:Inserting .txt file as html将 .txt 文件插入为 html
【发布时间】:2013-10-27 09:20:10
【问题描述】:

有没有办法将 .txt 文件插入网页并让服务器/浏览器将其解释为 html 而不仅仅是显示代码?

我尝试过如下使用 iframe,但这只是显示代码而不是解释代码。我知道这样做的明显方法是将文件另存为 .htm 并插入该文件;问题是,我的服务器不允许我上传 .htm 文件。

<iframe src="url.txt" type="text" width="100%" style="height:1000px"></iframe>

【问题讨论】:

    标签: html iframe embedding plaintext


    【解决方案1】:

    没有。为了被浏览器解释,它必须与Content-Type: text/html HTTP herader一起发送(文件扩展名本身无关,但经常被服务器用来猜测Content-Type)。所以如果你的服务器不允许你上传 HTML 文件,你就不能这样做。

    【讨论】:

      猜你喜欢
      • 2018-03-25
      • 1970-01-01
      • 2013-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-27
      • 1970-01-01
      相关资源
      最近更新 更多