windowFeature-values-target.html (848B)
1 <script> 2 const channelName = location.search.substr(1), 3 channel = new BroadcastChannel(channelName); 4 5 const haveOpener = window.opener !== null; 6 const haveReferrer = document.referrer !== null && document.referrer !== ""; 7 const allBarProps = [ 8 window.locationbar.visible, 9 window.menubar.visible, 10 window.personalbar.visible, 11 window.scrollbars.visible, 12 window.statusbar.visible, 13 window.toolbar.visible 14 ]; 15 const isPopup = allBarProps.every(x=>!x); 16 17 channel.postMessage({haveOpener, haveReferrer, isPopup}); 18 19 // Because messages are not delivered synchronously and because closing a 20 // browsing context prompts the eventual clearing of all task sources, this 21 // document should not be closed until the opener document has confirmed 22 // receipt. 23 channel.onmessage = () => window.close(); 24 </script>