0

I have an Add-in for outlook, that fetches the data from the email and perform its functionality.

Next, I am looking to have an iframe containing a webpage.

enter image description here

Is there a way to make some kind of communication between the add-in and the webpage?

Use case:

Let's say, Using office APIs I'll fetch the subject of the email, then I want the subject to be copied to google search (input), and from my search button (external see arrow) I could trigger the action.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
GMAC
  • 788
  • 4
  • 23

1 Answers1

0

Of course, because you still deal with a regular HTML document. Use contents() to access the Document object inside an iframe. For example:

$('[name=your_iframe]').contents().find('button').click(function() {
    alert('click');
});

See Attach an event in a child iframe to a handler in the parent window for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Uncaught DOMException: Blocked a frame with origin "https://localhost:3000" from accessing a cross-origin frame. Is it the local host issue? what if I redirect my :3000 to ngrok? – GMAC Dec 03 '21 at 16:17
  • See [Addressing same-origin policy limitations in Office Add-ins](https://learn.microsoft.com/en-us/office/dev/add-ins/develop/addressing-same-origin-policy-limitations). – Eugene Astafiev Dec 03 '21 at 17:08
  • You are suggesting to exchange data based on messages as mentioned here https://johnresig.com/blog/cross-window-messaging/ ? – GMAC Dec 07 '21 at 11:09
  • Is your query resolved?? – Outlook Add-ins Team - MSFT Dec 15 '21 at 11:43