I have a page A that opens a popup to B. Page B, after some jobs, always redirects to another page C in the pop up. Page C then dispatches an event to send some data to page A, but page A has no reference to page C to register the event handler. The code I tried is somewhat like this:
PageA:
function handler(e) {
alert(e.detail.message);
}
var popup = window.open('/PageB.aspx');
popup.addEventListener("dispatch", handler, false);
PageB:
location.href = "PageC.aspx";
PageC:
var event = new CustomEvent(
"dispatch",
{
detail: {
message: "Test"
},
bubbles: true,
cancelable: true
}
);
window.dispatchEvent(event);
But this is not working, because when I redirect, PageA misses the reference to PageC. Does anyone knows a way to fix this?