在IE中显示iframe中的blob失败

Show blob in iframe fails in IE

本文关键字:中的 blob 失败 iframe 显示 IE      更新时间:2024-03-03

所以,要点是,我将上传的文件下载到数据库,以在iframe 中显示它们,至少是其中的大部分

这是代码:

var ancho = $(window).width() * 0.90;
var alto = $(window).height() * 0.90;
$("#DialogoImagen").dialog({
    show: {
        effect: 'blind'
    },
    hide: {
        effect: 'blind'
    },
    width: ancho,
    height: alto,
    resizable: true,
    draggable: true,
    title: '',
    modal: true,
    position: { my: "center", at: "top", of: window }
});
$("#DialogoImagen").children().remove();
var iframe = $("<iframe width='98%' src='" + window.URL.createObjectURL(archivo) + "'/>");
$("#DialogoImagen").append(iframe);

这与其他世界无关,我用window.URL.createObjectURL(blob)设置了iframe src,与Chrome、FF、Opera完美配合,但IE,甚至11,都没有显示任何内容,不知道该怎么解决吗?

这取决于您使用的内容类型,但由于它是在IFRAME中运行的,因此IE肯定不支持该内容类型的数据URI。参考:犬科

根据上述参考,IE支持图像、CSS和脚本文件,但不支持HTML。我可以根据个人经验验证HTML数据URL,例如

data:text/html, <h1>Hi</h1><p>I'm a data URL

不要在IE10中工作。