简体   繁体   中英

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

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.

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