Hello SO,
I've got a situation a page on where a script on www.example.com/index.html opens home.example.com/foo.html in a popup window. When the user closes the popup, I want to notify the opener page by calling a Javascript function on it (which does a few things with the DOM). I use unbeforeunload like this: 
    // In index.html on www.example.com:
    window.fn = function () { /* Perform stuff after foo.html has closed */ }
    // In foo.html on home.example.com:
    window.onbeforeunload = function () {
        if (window.opener && window.opener.fn)
            window.opener.fn();
    };
This doesn't work because the web pages are on different domains. I can set the document.domain property to overcome this: 
document.domain = "example.com";
Unfortunately, this doesn't play well with the web app framework I use on the foo.html side (Apache Wicket), as it includes a script which does something like this:
var src = (window.location.protocol == 'https:') ? something : other;
Apparently, in IE6*, when you set the document domain, the location object becomes write-only, and so trying to read window.location.protocol throws "Access denied".
So, my question is: How do I allow cross-domain Javascript function calls while still allowing my scripts to read the contents of the location object? 
- I can't go via the server. (The work performed by the function I want to call doesn't really play that way.)
 - I can't read the 
window.location.protocolproperty before settingdocument.domainand then use that value in the conditional assignment; doing so would require me to rebuild the web framework libraries - not something I want to do. 
* Possibly in other versions of IE, too; haven't checked.