admin管理员组文章数量:1336098
We're creating <iframe>
s dynamically (e.g. for a rich text editor or a debug window) and injecting html into the src
. For years we used a javascript:
url as the src
similar to this answer until we ran into same-origin-policy issues with multiple independent iframes.
Our current solution is creating an object url for a blob that contains the html:
var iframe = document.createElement('iframe')
, html = '<h1>it works!</h1>'
, blob = new Blob([html], {type: 'text/html'})
, url = URL.createObjectURL(blob);
iframe.src = url;
document.querySelector('body').appendChild(iframe);
We're creating <iframe>
s dynamically (e.g. for a rich text editor or a debug window) and injecting html into the src
. For years we used a javascript:
url as the src
similar to this answer until we ran into same-origin-policy issues with multiple independent iframes.
Our current solution is creating an object url for a blob that contains the html:
var iframe = document.createElement('iframe')
, html = '<h1>it works!</h1>'
, blob = new Blob([html], {type: 'text/html'})
, url = URL.createObjectURL(blob);
iframe.src = url;
document.querySelector('body').appendChild(iframe);
This works fine in Chrome and Firefox, but not in IE11 (for browsers where URL
or Blob
are undefined we fallback to the javascript:
solution). IE11 raises SCRIPT5
: Access is denied
.
Are we misusing the APIs? Is there a special API for IE? A known workaround?
Share Improve this question edited May 23, 2017 at 11:45 CommunityBot 11 silver badge asked Dec 7, 2015 at 12:40 Dominik SchreiberDominik Schreiber 2,7711 gold badge26 silver badges38 bronze badges 1- 1 damn your issue is hard to figure out! I've changed the Security settings of my IE11 to the lowest possible config and I've sandboxed the iframe (html5rocks./en/tutorials/security/sandboxed-iframes) still the code snippet didn't work! There is one IE bug that I saw related to this which had no update whatsoever (connect.microsoft./IE/feedback/details/797361/…) Apparently, IE is seeing this as an XSS even though its a Blob URL...i don't think there's anything wrong with the API as Blobs are supported in IE11 – securecodeninja Commented Dec 7, 2015 at 23:43
2 Answers
Reset to default 4Unfortunately IE does not support DATA URI's*with a few caveats. I have the same issue, but with a PDF in an embedded tag.
It looks like you can use msSaveOrOpenblob to have IE open your blob file
IE 11 does not support all the Data URI's.
It supports only images and linked resources like CSS or JS. Please note HTML files are not supported.
本文标签: javascriptUsing Blob urls for src in IE11Stack Overflow
版权声明:本文标题:javascript - Using Blob urls for src in IE11 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742392631a2466291.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论