要获取DIV屏幕截图,请使用domtoimage.js文件,
https://ourcodeworld.com/articles/read/38/how-to-capture-an-image-from-a-dom-element-with-javascript 通过使用此文件进行下载,但是如何在下载之前将该文件保存到temp文件夹中。
function exportAsImage(){
var result= $('#dashboardChartData').text();
var nameOfChart=$('#exportAsImage').val();
var node = document.getElementById("dashboardChartData");
if(result.trim()!="No Data Available."){
$('#simplemodal-overlay').css('display','block');
domtoimage.toPng(node).then(function(dataUrl) {
var img = new Image();
img.src = dataUrl;
var link = document.createElement("a");
link.download = nameOfChart+".png";
$('#simplemodal-overlay').css('display','none');
link.href = img.src;
localStorage.setItem(img.src, link.download );
link.dispatchEvent(new MouseEvent(`click`, {bubbles: true, cancelable: true, view: window}));
link.remove();
});
} else {
bootbox.alert({
size: 'small',
title :'Alert',
message: "No Data Available",
});
}
}