Capture screenshot of iframe - html2canvas not working

做~自己de王妃 提交于 2019-12-20 03:27:15

问题


I have the following iframe:

<iframe name="content" src="" style="position: absolute; left: 0px; top: 28px;" allowtransparency="true" border="0" scrolling="yes" width="100%" frameborder="0" height="90%" id="MyFrame"></iframe>

I simply want to capture a screenshot of the iframe contents as they stand, I've tried html2canvas but it doesn't seem to work. I've tried placing the iframe inside a div but no joy.

I've seen various methods of achieving this using php, but nothing that seems clear. Can anyone shed any light?


回答1:


It's written in the limitations section of the doc: http://html2canvas.hertzen.com/documentation.html#limitations.

The script doesn't render plugin content such as Flash or Java applets. It doesn't render iframe content either.

Screen capture using JS raises security problems.

Recently I've been trying carota (https://github.com/danielearwicker/carota) with some success to render HTML text on a canvas. However, it only handles a small subset of HTML.

There is also the SVG foreignobjectapproach which makes it possible to render DOM objects in a canvas: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas

Unfortunately, it is not implemented in IE, including IE 11.



来源:https://stackoverflow.com/questions/27108487/capture-screenshot-of-iframe-html2canvas-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!