2015-07-11 142 views
0

試圖找出爲什麼這不起作用,它應該採取「你好」onload截圖,但沒有做任何事情?Html2Canvas:爲什麼這不起作用?

感謝所有能夠幫助我的人,我對JavaScript不熟悉,我只是用它來完成這個功能。

<html> 
<body> 
<script src="html2canvas.js"> 
    window.onload = function(){ 
    html2canvas(document.body, { 
    onrendered: function(canvas) { 
    document.body.appendChild(canvas); 
    }, 
width: 300, 
height: 300 
})}; 
</script> 
</body> 
<h1>Hello</h1> 

<canvas id="canvas" width="300" height="300" style="border:1px solid  #d3d3d3;"> 

</html> 
+0

您是否閱讀過文檔 - http://html2canvas.hertzen.com/documentation.html - 我認爲您在同一個目錄中具有** html2canvas.js **作爲HTML ... p.s.你不需要創建一個畫布,html2canvas函數爲你返回一個 –

回答

0

嘗試......

<html> 
<body> 
<script src="html2canvas.js"> 
    window.onload = function(){ 
    html2canvas(document.body, { 
    onrendered: function(canvas) { 
    document.body.appendChild(canvas); 
    }, 
width: 300, 
height: 300 
})}; 
</script> 
<h1>Hello</h1> 

<canvas id="canvas" width="300" height="300" style="border:1px solid  #d3d3d3;"> 
</body> 


</html> 

的和標籤中移動你的畫布和H1標籤。

+0

我仍然得到一個空白的畫布? @Ricky –