1
我想使用html2canvas保存圖像的截圖。以下是我的代碼:如何使用html2canvas獲取圖像的截圖?
var a = document.getElementById('a2')
html2canvas(document.getElementById('a1'), {
onrendered: function(canvas) {
var img = canvas.toDataURL("image/jpeg");
window.open(img);
}
}
但是,代碼保存本地圖像的屏幕截圖。但對於來自外部源的圖像,如: http://europa.promaticstechnologies.com/QuotePic/img/QuotePro/bg1.jpg 給我黑色截圖。請協助。
可能是因爲交叉來源 –
檢查此鏈接可能對其有用http://stackoverflow.com/questions/10457608/create-screenshot-of-webpage-using-html2canvas-unable-to-initialize-properly –