file_sync_xhr_document_write_with_iframe.html (487B)
1 <!DOCTYPE HTML> 2 <body> 3 <script> 4 function syncXHR() { 5 let xhr = new XMLHttpRequest(); 6 xhr.open("GET", window.location, false); 7 xhr.send(null); 8 } 9 10 addEventListener('load', () => { 11 syncXHR(); 12 document.open(); 13 document.write( 14 '<body>' + 15 '<iframe src="about:blank"></iframe>' + 16 // eslint-disable-next-line no-useless-concat 17 '<script>window.opener.postMessage("DONE", "*");</' + 'script>' + 18 '</body>'); 19 document.close(); 20 }, { once: true }); 21 </script> 22 </body>