對於我的javascript應用程序,我需要在我的ipad演示文稿中採用每個頁面的屏幕截圖,無論如何,我找到了使用html2canvas的解決方案。現在我能夠將html頁面轉換爲圖像,但是如何將其保存在使用javascript的演示文稿圖像文件夾中?如何將從畫布轉換而來的圖像保存到本地文件夾中?
這裏是我的javascript
html2canvas(document.body,
{
onrendered: function(canvas)
{
var test = document.getElementsByClassName('test'); //finding the div.test in the page
$(test).append(canvas); //appending the canvas to the div
var canvas = document.getElementsByTagName('canvas');
$(canvas).attr('id','test'); //assigning an id to the canvas
var can2 = document.getElementById("test");
var dataURL = can2.toDataURL("image/png"); //converting the canvas to image(PNG)
document.getElementById("image_test").src = dataURL; //assigning the url to the image
$(canvas).remove(); //removing the image
},logging:true,background: "#fff",
});
,這裏是我的html
<div class="wrapper">
<div class="container">
<div class="test">
<img src="" id="image_test">
</div>
</div>
</div>
任何人可以幫助我,我怎麼能ID爲「image_test」將圖像保存在我的演示圖片文件夾?
在此先感謝。
客戶端JavaScript(在瀏覽器中)不會讓你寫入到磁盤或保存任何數據(除非在像localStorage這樣的非常受控的情況下)。 – binaryatrocity