需要一个只有 javascript 且没有额外库文件 (-> jquery,...) 的工作代码,从整个网页截取屏幕截图。(从上到下页面)
目前我有这个不起作用,为什么?
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
var window = document.getElementById('item');
var canvas = document.getElementById('my-canvas');
var ctx = canvas.getContext("2D");
ctx.drawImage(window, 0,0, 100, 200, "rgb(255,255,255)");
canvas.toDataURL("image/png");
});
</script>
</head>
<body id="item">
test website
<canvas id='my-canvas'></canvas>