How to send a value from a pop-up window to the Office app RRS feed

  • Question

  • My Office app creates a pop-up window for the user to go through an OAuth process. At the end of the process, the pop-up window is redirected to a HTML with JavaScript which I create on the server. I tried different ways to pass a value back from the pop-up window to the App but none of them worked. The way I tried are:

    1) define a global function on the parent window and call the function from the pop up window by window.parent.callbackFunct.

    2) use HTML5 localStorage. The pop-up window sets the value to localStorage before closing, and the parent window reads the localStorage for the value.

    3) postMessage. The parent window defines a event listener function, and the pop-up window sends a message to the parent window by window.parent.postMessage('value','*')

    I suppose the first two ways are blocked by the Same Origin Policies. The third way I was really expecting it to work but it didn't. BTW, I am using IE 10. Update Versions: 10.0.11 to be exact.

    Any suggestions? Thanks for your help in advance.

    Friday, January 10, 2014 7:15 PM

All replies

  • According to your description, you want to send the value from popup window. Have you tried to use window.showModalDialog to return the value you wanted. The code below runs well for me.

    For open a new window:

            function OpenNewWindow()
                var someValue = window.showModalDialog("BlankPage.html", "", "dialogWidth=500px;dialogHeight=500px;status=no;help=no;scrollbars=no");

    For the popup window:

            function CloseMe()
                parent.window.returnValue = "Hello";
          <input type="button" value="CloseMe" onclick="CloseMe()" />

    Hope it can help you.

    Best regards

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 13, 2014 10:56 AM
  • Tried it. A couple of reasons why it doesn't meet my requirements:

    1) The pop-up window will navigate through a number of page for user authentication, but the showModalDialog will pop up another browser window when it navigates away from the original page.

    2) I tried to call postMessage in the window of showModalDialog. The message doesn't reach the parent window.

    Friday, January 17, 2014 8:15 PM
  • Hi Seangle,

    I sort of have the same problem here. Have you figured out a way to do it? I'd really appreciate it if you could share.Thanks.


    Thursday, March 13, 2014 7:21 PM
  • Have you tried this way for postMessage, add a <iframe> which "src" is assigned to your popup window or the HTML you create on server. I did this way before, and the postMessage works well.
    Friday, March 14, 2014 4:44 AM
  • Hi Rina,

    I had to drop the idea of pop up window as I couldn't find a solution to it. I was working with a Microsoft support engineer to find out why. We think it is because of the way how Office App creates a new window. In a standalone IE10, the pop-up window is a child process of the opener IE process. In OfficeApp with Excel/IE10, the pop-up window is a child process of a new IE process, i.e. a separate process from the opener IE process. In the standalone case, cross window messaging works because the pop-up window process is in the opener IE process.

    I worked around this problem by using iFrame in a JQuery dialog. And the HTML/JavaScript in iFrame sends message to the main window by calling:

        window.parent.postMessage("msg content", "*");

    Friday, March 14, 2014 7:27 PM