navigate-none.sub.html (1041B)
1 <!doctype html> 2 <script> 3 let current = new URL(window.location.href); 4 let navigateTo = current.searchParams.get("to"); 5 let channelName = current.searchParams.get("channelName"); 6 let postMessageTo = current.searchParams.get("postMessageTo"); 7 current.search = ""; 8 if (navigateTo) { 9 let next = new URL(navigateTo, current); 10 window.addEventListener("load", () => { 11 window.location.href = next.href; 12 }); 13 } 14 15 let target = undefined; 16 if (channelName) { 17 target = new BroadcastChannel(channelName); 18 } else if (postMessageTo) { 19 target = eval(postMessageTo); 20 } 21 22 if (target) { 23 // Broadcast only once the DOM is loaded, so that the caller can 24 // access reliably this document's body. 25 window.addEventListener("DOMContentLoaded", () => 26 target.postMessage("loaded", "*")); 27 28 // The page can also be restored from the back-forward cache: 29 window.addEventListener('pageshow', function(event) { 30 if (event.persisted) 31 target.postMessage("loaded", "*"); 32 }); 33 } 34 </script>