关于html2canvas javascript 截取网页快照

html2canvas 官网链接:http://html2canvas.hertzen.com/

引入html2canvas.min.js

    //网页区域截屏快照
    //mainDiv 需要截屏快照的区域
    function takeScreenshot() {
    	//参数配置
        var opts = {
            logging: false, //日志开关,发布的时候记得改成false
            windowWidth:1920,
            windowHeight:1080
        };
        setTimeout(function(){
            html2canvas(document.getElementById('mainDiv'),opts).then(canvas => {
                var url = canvas.toDataURL();
                //document.getElementById("load_sltimgs").appendChild(canvas)
                $("#load_sltimgs img").attr("src",url);
            });
        },10)
    }

你可能感兴趣的:(javascript)