将Blob设置为"src"iframe的 [英] set a Blob as the "src" of an iframe

查看:487
本文介绍了将Blob设置为"src"iframe的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在Chrome中完美运行

The following code work perfectly in 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.有人可以告诉我这是怎么回事.

But it is not working with IE. Can some one please tell me what is wrong here.

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

The iframe "src" also set to the blob as shown below.

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

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

Note: I went on the window.navigator.msSaveOrOpenBlob(newBlob) path as well but no luck so far.

推荐答案

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

According to http://caniuse.com/#feat=datauri IE 11 has only got partial support for Data URI's. It states support is limited to images and linked resources like CSS or JS, not HTML files.

根据此规范,必须对非base64编码的SVG数据URI进行uriencode才能在IE和Firefox中使用.

Non-base64-encoded SVG data URIs need to be uriencoded to work in IE and Firefox as according to this specification.

这篇关于将Blob设置为"src"iframe的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆