Html 如何在iframe中显示doc、xls、pdf和txt文件?

Html 如何在iframe中显示doc、xls、pdf和txt文件?,html,asp.net,Html,Asp.net,使用html的“框架”显示文件,但仅在“框架”中显示PDF和文本文件,下载doc和x ls文件而不显示 以下是示例代码: <html> <head> <meta name="generator" content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" /> <title>

使用html的“框架”显示文件,但仅在“框架”中显示PDF和文本文件,下载doc和x ls文件而不显示

以下是示例代码:

<html>
  <head>
    <meta name="generator"
    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
    <title>Open Word in Iframe</title>
  </head>
  <body>
    <div align="center">
      <table border="1" cellspacing="1" cellpadding="1" width="100%">
        <tr>
          <td width="25%" align="left" valign="top">
            <a href="doc1.pdf" target="awindow">Doc 1</a>
            <br />
            <a href="doc2.doc" target="awindow">Doc 2</a>
            <br />
            <a href="doc3.text" target="awindow">Doc 3</a>
          </td>
          <td width="75%" align="center" valign="top">
            <iframe name="awindow" frameborder="2" width="580" height="440" src="doc.txt"></iframe>
          </td>
        </tr>
      </table>
    </div>
  </body>
</html>

Iframe中的openword



您需要为web服务器配置MIME类型,以避免在远程客户端直接请求这些文件类型时(即不通过web脚本)下载这些文件类型


.doc和.xls文件类型在默认情况下可能没有配置,因此它们默认为MIME类型,只需下载即可,而不必在浏览器中显示。顺便说一句,默认情况下,标准浏览器不知道如何显示Microsoft特定的文件类型,因此您可能需要一个扩展名/插件/flash对象来正确显示它。

要显示没有插件的Word/Excell/PDF等文件,请使用Google Drive Viewer。
使用
而不是
,文件将被加载。

您可以尝试提供一个链接,与google doc viewer基本url相结合,使google doc打开该文件并将其显示为html。此处的更多信息:该url没有任何信息。您可以在这个问题中看到一些示例: