简体   繁体   中英

Capture screenshot of iframe - html2canvas not working

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?

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 foreignobject approach 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.

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