Created
November 7, 2017 07:24
-
-
Save hirokiky/bce929937e7bfca2af53b523e9078db6 to your computer and use it in GitHub Desktop.
Taking Screen Shots of main window from child popup window.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="/js/html2canvas.min.js"></script> | |
</head> | |
<body> | |
<button class="screen-shot">ScreenShot</button> | |
<script> | |
var btn = document.querySelector('.screen-shot'); | |
btn.addEventListener("click", function() { | |
if (!window.opener || window.opener.closed) { | |
window.alert('no opener window'); | |
return false; | |
} | |
html2canvas(window.opener.document.body, { | |
allowTaint: true, | |
useCORS: true, | |
}).then(function(canvas) { | |
document.body.appendChild(canvas); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment