Search code examples
javascriptflashactionscriptinternet-explorer-11window.opener

Invoking a JS method exposed by Flex app from a secondary window


I'm currently working on an old application made in Flex (so, basically, Flash) that is still required to work in IE11 (I know... I know). This webapp (let's call it A) exposes a method callable from JavaScript. A also has a button to open a new browser window (call it B). B has a listener on "beforeunload" event: when the user is going to close B, B has to call the JS method in A. Hope I explained it right. Using Google Chrome with the parameter "--disable-web-security" the method defined in A is executed and we're happy with that. We're using the following instruction:

window.opener.document.getElementById('flashAppID').methodName();

The issue we're facing is that IE11 throws the following Exception when B is trying to execute the JS method in A:

   {
      [functions]: ,
      __proto__: {
         [functions]: ,
         __proto__: {
            [functions]: ,
            __proto__: null
         },
         message: "",
         name: "Error"
      },
      description: "Authorization denied",
      message: "Authorization denied",
      name: "Error",
      number: -2146828218,
      stack: "Error: Authorization denied
   at callOpener (http://domainname.ext/pageB.html:18:21)"
   }

We tried to disable any possible security restriction in IE but without luck; has anyone a suggestion on how to avoid that exception?

Thanks in advance.


Solution

  • The issue was caused by the following assignment, written for unknown reasons by previous developers:

    document.domain = "domainname.ext";
    

    After commenting that line, everything started to work as expected. So if anyone will face the same or similar issue, please be sure not to overwrite document.domain property.