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