简体   繁体   中英

render blob to popup div instead of opening in new window

Currently I can download a blob and render it in a new window like this:

const blob = new Blob([downloadEvent.response], { type: mimeType });

const URL = window.URL || (window as any).webkitURL;

const blobUrl = URL.createObjectURL(blob);

window.open(blobUrl);

Is it possible to somehow open the blob in a popup div instead of a new window.

Using an iframe should work:

 const iframe = document.createElement("iframe");
 iframe.src = blobUrl;
 /*your favorite DOM node */.appendChild(iframe);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM