I have a JavaScript file attached to a webpage called 'navigate.js' It contains a collection of methods that look like this:
var ContractWindow;
function showContract(ContractID){
try{
if(ContractWindow){
if(!ContractWindow.closed){
ContractWindow.close;
}
}
ContractWindow = window.open(contract.aspx?contractid=" + ContractID, "ContractEditor",
"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=780,height=615");
}
}catch(exc){
alert(exc.message);
}
}
(there are similar functions to open pages for editing product categories, products, regions...etc.)
Each of several functions opens up a different editor page in its own window, with the goal that only one window of any given type (where type="ContractEditor") should be open at any given time.
If an editor (in this case the Contract Editor) is reused we want to close the previous window first so that subsequent window.open
will cause the new window to come to front of any windows (have focus).
Everything works as expected until the page has been idle for approximately 10 minutes. After which the alert message reads: The object invoked has disconnected from its clients
Various tests have revealed that the exception comes from the assignment of the return value of window.open to the ContractWindow variable. If I leave out ContractWindow =
and just call window.open
, it works but the window does not 'pop' to the forefront which is a requirement. (window.open reuses the existing window named "ContractEditor" but does not bring it forward from the stack of open windows.)