adopt-from-image-document.html (578B)
1 <!doctype html> 2 <title>Adopt img from image document</title> 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-img-element"> 4 <link rel="match" href="document-base-url-ref.html"> 5 <!-- Counteract any style added by the image document --> 6 <style>img { width: initial; height: initial; }</style> 7 <iframe></iframe> 8 <script> 9 var iframe = document.querySelector('iframe'); 10 iframe.onload = function() { 11 let img = iframe.contentDocument.body.firstChild; 12 document.body.appendChild(img); 13 iframe.remove(); 14 }; 15 iframe.src = 'resources/cat.jpg'; 16 </script>