frameElement-sibling-accessor.html (744B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>This page will attempt to access the frameElement of its sibling and report the results on request</title> 4 5 <h1>I did get loaded</h1> 6 7 <script> 8 "use strict"; 9 10 window.onmessage = e => { 11 const { newDocumentDomain } = e.data; 12 if (newDocumentDomain) { 13 document.domain = newDocumentDomain; 14 } 15 16 const siblingWindow = parent.frames[0]; 17 18 try { 19 const { frameElement } = siblingWindow; 20 21 let result = "something wierd happened"; 22 if (frameElement === null) { 23 result = "null"; 24 } else if (frameElement.constructor) { 25 result = frameElement.constructor.name; 26 } 27 28 parent.postMessage(result, "*"); 29 } catch (e) { 30 parent.postMessage(e.name, "*"); 31 } 32 }; 33 </script>