gpt4 book ai didi

javascript - 将 Blob 设置为 iframe 的 "src"

转载 作者:可可西里 更新时间:2023-11-01 02:26:06 25 4
gpt4 key购买 nike

以下代码在 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>

但它不适用于 IE。有人可以告诉我这里出了什么问题吗?

iframe“src”也设置为 blob,如下所示。

<iframe id="myFrame" src="blob:0827B944-D600-410D-8356-96E71F316FE4"></iframe>

注意:我也继续使用 window.navigator.msSaveOrOpenBlob(newBlob) 路径,但到目前为止运气不好。

最佳答案

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

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

关于javascript - 将 Blob 设置为 iframe 的 "src",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29667922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com