javascript - html2canvas, realizing screenshots and image cross-domain issues.
给我你的怀抱
给我你的怀抱 2017-05-16 13:44:33
0
1
929
  1. Cross-domain issues are also reported when using local images to generate screenshots.

<p id="navp">
    <a onClick="testFun();">
        <p class="title-msg">美的国际支持部美国加利福尼亚州综合统计报表</p>
        <p>
            <img id="imgTest" src="images/worldMap.png">
        </p>
    </a>
</p>
html2canvas(document.getElementById('navp'),{
    allowTaint:true,
    height: 500
}).then(function(canvas) {
    var aTag = document.createElement("a");
    aTag.innerHTML = "This is a test";
    aTag.setAttribute("href", canvas.toDataURL());
    aTag.setAttribute("download", "myPic.png");
    document.body.appendChild(aTag);
});

给我你的怀抱
给我你的怀抱

reply all(1)
给我你的怀抱

http://stackoverflow.com/ques...

To use canvas to read images, it is best to start a local web service to start this page (otherwise it is considered cross-domain). Don't just open the local html file with the browser.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template