[英]How can I save multiple divs as an image?
I'm trying to build an interface for the user, so he can choose or pick colored eyes, skin, etc., of a model. 我正在尝试为用户建立一个界面,以便他可以选择或选择模型的彩色眼睛,皮肤等。 I'm really on my way with div
s and CSS. 我真的在使用div
和CSS。 I'm using Ajax for loading images into the div
s. 我正在使用Ajax将图像加载到div
。
My problem is that I need to offer a option to the user so he can save the image as a JPEG or PNG file. 我的问题是,我需要向用户提供一个选项,以便他可以将图像另存为JPEG或PNG文件。
Looking around, I found canvas HTML5 stuff on Stack Overflow, but it's not compatible with Internet Explorer, 环顾四周,我在Stack Overflow上发现了HTML5画布的内容,但它与Internet Explorer不兼容,
I need help to find something compatible with all browsers. 我需要帮助来查找与所有浏览器兼容的内容。
I also found this JavaScript code: 我还找到了以下JavaScript代码:
button = document.createElement("img");
button.src = "http://example.com/livechart.gif?interval=15"
But I don't know much about the createElement
method. 但是我对createElement
方法了解不多。
I know CSS, but JavaScript is beyond my knowledge. 我知道CSS,但是JavaScript是我所不了解的。
You cannot do this on the browser, you must do it on the server. 您不能在浏览器上执行此操作,而必须在服务器上执行此操作。
see: Convert web page to image 请参阅: 将网页转换为图像
我相信您可以使用HTML canvas和一些JavaScript来做到这一点: Canvas2Image:将Canvas数据保存到图像文件 。
You want to take screenshot of the browser? 您要获取浏览器的屏幕截图吗? Well, there are lot of ways you could try , but all of them would be browser-specific. 好了,您可以尝试多种方式,但是所有方式都将特定于浏览器。 The most reliable would be to just tell the user to make a screenshot with the OS. 最可靠的方法就是告诉用户使用OS进行屏幕截图。 On a Mac it's Command-Shift-4, then space; 在Mac上是Command-Shift-4,然后是空格; on a PC, it it's ALT-PrtScr, I think. 我认为是PC上的ALT-PrtScr。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.