How to make a screenshot of an embedded iframe

三世轮回 提交于 2019-12-12 15:55:06

问题


I want to have a function that make a snapshot of the iframe and append to the other area of the webpage. The codes should look like:

Html:

<iframe src="http://edition.cnn.com/video"></iframe>
<button id="btn_screenShot" name="screenShot">Grab a image</button>
<div id="screenShot-result"></div>

JS:

function screenShot(iframe) {
   //what can I do here?
   //transform the page in <iframe> to a image type, jpeg,png or any other!
}

$('#btn_screenShot').click(function(){
   var imgPath = screenShot(document.getElementByTagName('iframe'));
   $('#screenShot-result').append("<img src=\"+ imgPath +\">");
});

First, it doesn't work with html2canvas, like the limitation described. Is there any other javascript or jquery plugin to realize the function? or is it possible to work like the print-screen button on the keyboard?

来源:https://stackoverflow.com/questions/17453019/how-to-make-a-screenshot-of-an-embedded-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!