IE6 Object Impotent
Internet Explorer is object impotent. Recently I have started using more advanced Javascript objects structures in my web applications. This beautifies and simplifies the code. Its the right thing to do — except that IE just can’t their objects to propagate, if you know what I mean It took me a while to figure this out, so maybe I can save someone else some valuable time.
IE can import objects into a child window, but it cannot pass an object back to the parent/opener window. When this happens, you will run into the following error:
The callee (server[not server application]) is not available and disappeared; all connections are invalid. The call did not execute.
To fix the problem, create functions in the opener.window or parent.window to build/rebuild/set the objects there. Then call the functions from the child window.
My Scenario:
Main application window trackes times of different events. These times are stored as date objects in a single object called TIMESTAMPS.
When user clicks a button, a new window to verify the times pops up. The window will modify the value of the Date objects in the TIMESTAMPS object in the opener.window.
When the dates are verified, the child window with create new date objects to replace the existing opener.window.TIMESTAMPS objects.
You don’t notice the problem right away, but the next time you try to access these new date objects, you will recieve the error above.
This only happens in IE, all other browsers operate correctly.
Solution:
Instead of passing the new date objects created in the child window, I created a function in the opener.window to build the objects there. I call the opener function from the child window. This works well.
Here is the JavaScript function in the opener window:
function setTimestampObject(objName, jsEpoch)
{
TIMESTAMPS[objName] = new Date(jsEpoch);
}
To set the new date objects I create the date object locally in the child window, but pass the Javascript Epoch timestamp to the opener.setTimestampObject() function like this:
opener.window.setTimestampObject('starttime', newStart.getTime());
opener.window.setTimestampObject('endtime', newEnd.getTime());
This will create new starttime and endtime date objects in opener.TIMESTAMPS. So now we can successfully change the values of opener.TIMESTAMPS.starttime and opener.TIMESTAMPS.endtime from the child popup window.
Summary:
IE is impotent. This is just another way that IE is far behind the pack. Urge your friends and colleagues to switch to a standands compliant browser like Firefox. Until Microsoft really makes an effort to fully implement standards, remove security flaws, and fix their existing functionality quirks, their browser should be rightly considered an inferior product.