DOMException:阻止源为“ http:// localhost:9000”的框架访问跨域框架

问题描述

我想获取iframe的屏幕截图,我使用Angular 9。

enter image description here

component.html:

 <div>
   <img id='img' />
 </div>

<div>
     <iframe id="iframe" *ngIf="fileUrl" [src]="getFileUrl()"></iframe>
</div>

component.ts:

// take screenshot
var body = $('iframe').contents().find('body')[0];
      html2canvas(body).then((canvas: any) => {
        var base64encodedstring = canvas.toDataURL("image/jpeg",1);
        $('#img').attr('src',base64encodedstring);
      });

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)