I have a application which loads two html pages , I want to fire custom event from one html page which will be listened by other html page , is it possible ? Right now I have fired custom event but its listened only by the same page , other page is not listening to this event.
Here is my code in first html page::
var event= new CustomEvent(
"myeventtype",
{
detail: {
name: "",
details: ""
},
bubbles: true,
cancelable: true
}
);
window.dispatchEvent(event );
//handler
function myHandler(e) {
alert(e.detail.name);
}
//listener
window.addEventListener("myeventtype", myHandler);
second html page only add listener and handler::
window.addEventListener("myeventtype", testHandler);
//handler
function testHandler(e) {
alert(e.detail.name);
}
why my second page is not listening to this event, am i doing something wrong here, please get me out of this.
thanks,