截获iframe的截图 - html2canvas无法正常工作 [英] Capture screenshot of iframe - html2canvas not working

查看:1521
本文介绍了截获iframe的截图 - html2canvas无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下iframe:

 < iframe name =contentsrc =style =position:绝对;左:0px;上:28px; allowtransparency =trueborder =0scrolling =yeswidth =100%frameborder =0height =90%id =MyFrame>< / iframe> 

我只是想截取iframe内容的截图,我试过html2canvas但它似乎没有工作。我已经尝试将iframe放置在div中,但没有快乐。



我已经看到了使用php实现这一点的各种方法,但没有任何看起来很清楚。任何人都可以摆脱任何光线?

解决方案

它写在文档的限制部分: http://html2canvas.hertzen.com/documentation.html#limitations


脚本不呈现插件内容,例如Flash或Java
小程序。它不呈现iframe内容。


使用JS的屏幕截图引发安全问题。



最近我一直在尝试carota( https://github.com/danielearwicker/carota)在画布上呈现HTML文本方面取得了一些成功。但是,它只处理HTML的一小部分。

还有SVG foreignobject 方法,可以在画布中呈现DOM对象: https://developer.mozilla.org/zh-CN/docs/Web/ API / Canvas_API / Drawing_DOM_objects_into_a_canvas



不幸的是,它并没有在IE中实现,包括IE 11在内。


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

这篇关于截获iframe的截图 - html2canvas无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆