我有一个涉及 CSS 3D 渲染器的三个 JS 应用程序。我正在使用 html2canvas 库来截取 document.body 的屏幕截图。
唯一的问题是它会截取除 CSS 3D 渲染器之外的所有内容的屏幕截图。
下面是截图的代码:
window.addEventListener("keyup", function(e){
//Listen to 'P' key
if(e.which !== 80) return;
html2canvas(document.body, {
onrendered: function(canvas) {
var img = canvas.toDataURL();
window.open( img , 'Final' );
}
});
});
如需演示,请访问:
http://nobelbrothers.com/test/CanvasShot和 http://nobelbrothers.com/CanvasShot
注意:按P键截屏(需要关闭弹出窗口拦截器)。
谢谢
最佳答案
感谢 file saver js lib 我实现了此功能
<script type="text/javascript" src="js/filesaver.js"></script>
window.addEventListener("keyup", function(e){
//Listen to 'P' key
if(e.which !== 80) return;
Render.domElement.toBlob(function(blob) {
saveAs(blob, "Final");
});
});
关于javascript - 如何在三个JS中截取CSS 3D渲染器的屏幕截图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24463794/