将Blob设置为iframe的"src"

Hir*_*ran 11 javascript iframe internet-explorer blob

以下代码在Chrome中完美运行

<script>
function myFunction() {
var blob = new Blob(['<a id="a"><b id="b">hey!</b></a>'], {type : 'text/html'});
var newurl = window.URL.createObjectURL(blob);
    document.getElementById("myFrame").src = newurl;
}
</script>
Run Code Online (Sandbox Code Playgroud)

但它不适用于IE.有人可以告诉我这里有什么问题.

iframe"src"也设置为blob,如下所示.

<iframe id="myFrame" src="blob:0827B944-D600-410D-8356-96E71F316FE4"></iframe>
Run Code Online (Sandbox Code Playgroud)

注意:我也走了这window.navigator.msSaveOrOpenBlob(newBlob)条路,但到目前为止没有运气.

小智 5

根据http://caniuse.com/#feat=datauri,IE 11 仅部分支持数据 URI。它声明支持仅限于图像和链接资源,如 CSS 或 JS,而不是 HTML 文件。

根据本规范,非 base64 编码的 SVG 数据 URI 需要进行 uriencoded 才能在 IE 和 Firefox 中工作。