Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE html>
<script>
// When told, register an unload handler that will trigger a beacon to the
// URL given by the sender of the message.
window.addEventListener('message', e => {
var url = e.data;
window.addEventListener('unload', () => {
navigator.sendBeacon(url, 'blah');
});
window.parent.postMessage('navigate-away', '*');
});
</script>