How to create an image of the website using js?

我与影子孤独终老i 提交于 2019-12-11 06:39:43

问题


Can I "convert" the website to a JPG or GIF? I mean, is it possible to view the website as an image? (obviously without animation) only a static image, like a photo of the website that the user is seeing on the browser...

Thank you!


回答1:


No it is not possible, since the way the website looks is just how a browser renders it, it can be different sizes and there are many variables to the way your page looks. You can do it server-side using PHP but it won't be simple at all, it would mean your server has to have a browser that will generate the website, save it as an image on the server, and send it to the user.




回答2:


Firefox added something similar to this to their canvas implementation. You can find CanvasRenderingContext2D.drawWindow() documented in their wiki. It is restricted to being used by plugins, for security purposes, and isn't supported by any other browsers.

There is talk of adding support to other browsers, and perhaps removing some of the security restrictions, but that is probably a long way off. For now, there isn't a good JavaScript solution to your problem.



来源:https://stackoverflow.com/questions/6299714/how-to-create-an-image-of-the-website-using-js

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