简体   繁体   English

将iframe放在HTML5中的canvas元素中

[英]put iframe inside a canvas element in HTML5

我的问题很简单,实际上我想把iframe元素(可以包含视频,网页,图片,pdf等)显示在元素上,它不需要可编辑,只需显示就够了

I am not sure whether you want to display it on top of it or draw it onto the canvas. 我不确定您是想在它上面显示它还是将它绘制到画布上。 The first is possibly by absolutely positioning the element above the canvas (or below it if you want to draw additional things over it). 第一种可能是将元素绝对定位在画布上方(如果您想在其上绘制其他内容,则可以在其下方)。 The second is impossible (except if you are running in a chrome extension or firefox add-on which isn't the case I assume (if it is the case than the function is called DrawElement on the cavnas context)). 第二个是不可能的(除非你在chrome扩展或firefox附加组件中运行,这不是我假设的情况(如果是这种情况,那么在cavnas上下文中函数被称为DrawElement))。 There have been some projects which attempt to manually make a 'screenshot' of a page ( Can you take a "screenshot" of the page using Canvas? ), but that still wouldn't work with pdf files. 有些项目试图手动制作页面的“屏幕截图”你可以使用Canvas获取页面的“截图”吗? ),但这仍然无法用于pdf文件。 Video content in a html5 video tag can similarly be drawn to the canvas manually, although again the controls etc. would have to be drawn manually. html5视频标签中的视频内容可以类似地手动绘制到画布上,但同样必须手动绘制控件等。

The reason why it's not possible to draw the entire element to the canvas is as a security precaution to prevent developers to get information about external pages (although there have been discussions about allowing this and accepting that the canvas will get 'tainted' meaning nothing can be read from it, but the consensus was that positioning the element below the canvas is far more usefull in that case). 之所以无法将整个元素绘制到画布上是为了防止开发人员获取有关外部页面的信息,这是一种安全预防措施(尽管已经讨论过允许这样做并接受画布将被“污染”意味着什么都没有可以从中读取,但大家一致认为将元素定位在画布下方在这种情况下更有用)。 If you want to read into these security considerations you should look up Bug 69044 in the webkit engine. 如果您想了解这些安全注意事项,您应该在webkit引擎中查找Bug 69044。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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