I have a web application that consists of two websites - one running on port 8080 (java) and other running on port 80 (IIS). The java web pages call into IIS web pages, which occassionally call back into java web pages to get additional information. The javascript that handles the communication/ exchange of data works in IE but not in Firefox.
Page 1 (IIS) > onClick of Button > Page 2 (Java/Tomcat) > User closes popup > Data transfer to Page 1
Here is the Javascript
if(window.attachEvent){//IE exclusive method for binding an event
alert("AttachEvent");
window.attachEvent("onfocus", Focus_onfocusEvent);
window.objExitPopupWindow.attachEvent("onunload", Focus_onunloadExitEvent);
}else if(window.addEventListener){//DOM method for binding an event. W3C standard
try{
alert("Event Listener");
window.addEventListener("focus", Focus_onfocusEvent, true);
window.objExitPopupWindow.addEventListener("unload", Focus_onunloadExitEvent, true);
}catch(err){
alert(err);
}
}
The issue I run into is a) In firefox, if I have the alert("EVent Listener"); enabled then I get an error about Error: Permission denied for "http://localhost" to get property Window.addEventListener from "http://localhost:8080". b) In firefox, if I do not have the alert on, then there is no error message shown but it looks like it does Focus_onuloadExitEvent first then Focus_onfocusEvent, all in the process of opening the popup. Closing the popup does not fire Focus_onunloadExitEvent.
How do I make sure that the code behaves properly in both Firefox and IE - ie. I want the onfocusEvent to fire on popup focus and onunloadEvent to fire on popup unload.
TIA