2013-11-24 35 views
0

如果div的位置是绝对的,如何获取屏幕截图?
我收到错误:“Uncaught IndexSizeError:索引或大小为负值,或大于允许值” 我想添加png图像,一个是最多的,所以我用z-index
我的html :当div的位置是绝对时获取屏幕截图

<div id="divFrame"> 
     <img id="frame"> 
     <div id="zoom" class="zoomProps" ><img id="polaroid"/> </div> 
</div> 

CSS:

.zoomProps { 
top: 0; 
left: 0; 
width: 100%; 
z-index: 2; 
position: absolute; 
} 
#frame { 
left: 0; 
top: 0; 
width: 100%; 
z-index: 3; 
pointer-events: none; 
position: absolute; 
    } 

JQuery的:

html2canvas(document.getElementById('divFrame'), { 
onrendered: function(canvas) { 
    var img = canvas.toDataURL(); 
    $("#yemekPageImgFullScreen").attr('src', img); 
    $("#popupBasic").popup(); 
    $("#popupBasic").popup('open'); 
} 
    }); 

回答

1

重复:已问/回答here

引用前面回答:

Thishtml2canvas bug报告。

我能修复Uncaught Error:IndexSizeError:DOM Exception 1通过修补html2canvas.js文件。本

替换此

var imgData = canvas.getContext("2d").getImageData(bounds.left, bounds.top, bounds.width, bounds.height); 
ctx.putImageData(imgData, 0, 0);