从 iframe 查看 zip 存档中的 HTML 个文件

View HTML file in zip acrhive from an iframe

是否可以在 HTML 中使用 iframe 查看 .zip 存档中的 index.html 文件?或者是否存在一些可以执行此操作的 JS 库?

提前致谢。

我只是想进一步详细说明@Vohuman 的评论,因为我认为它很重要。

根据我对 jszip 库文档的理解,它可以完成。

  1. 读取 zip 文件(使用 JSZipUtils)
JSZipUtils.getBinaryContent('path/to/content.zip', function(err, data) {
  if(err) {
    throw err; // or handle err
  }

  var zip = new JSZip(data);
});

来源:https://stuk.github.io/jszip/documentation/howto/read_zip.html

  1. 使用以下方式阅读:
var new_zip = new JSZip();
// more files !
new_zip.load(content);

// you now have every files contained in the loaded zip
new_zip.file("hello.txt").asText(); // "Hello World\n"

来源:https://stuk.github.io/jszip/documentation/examples.html(滚动页面底部(Read a zip file 部分))

  1. 最后,创建一个 iframe 并将 html 内容放入其中。
$('#your_iframe').contents().find('html').html(htmlZipContent);