Using Window.open when third party cookie is disabled does not return the value of postMessage

106 views
Skip to first unread message

rajatha k

unread,
Mar 5, 2021, 4:01:09 AM3/5/21
to Google Apps Script Community

In our Google workspace add-on, we followed the example by https://tanaikech.github.io/2018/02/20/open-site-with-new-window-using-google-apps-script/ to open a third party URL in a new tab rather than in an iframe when the third party cookies are disabled.


Here is our implementation,

function openNewTab() {

var url = ‘third party URL’;

 var js = " \

    <script> \

      var windowRef = window.open('" + url +"'); \

      console.log(windowRef ); \

      window.addEventListener('message', handleMessage, false); \

      function handleMessage(e) { \

      console.log(e); \

      windowRef.top.window.close(); \

      }\

      console.log('Window ref'); \

    </script> \

var html = HtmlService.createHtmlOutput(js)

    .setHeight(10)

    .setWidth(100);

  DocumentApp.getUi().showModalDialog(html, 'Now loading.');

}


What we are trying to achieve is that the third party URL communicates back via postMessage event, we are unable to capture it. 
Is there something we are missing from the above implementation

Reply all
Reply to author
Forward
0 new messages