Legacy Dev Forum Posts

 View Only

Sign Up

Embeddable Framework - accessing parent page

  • 1.  Embeddable Framework - accessing parent page

    Posted 06-05-2025 18:47

    vitaly | 2018-07-02 19:41:34 UTC | #1

    Hi,

    What is the correct way to send a message from the framework.js, say screenPop method, to the parent HTML page?

    Thanks


    tim.smith | 2018-07-02 19:48:49 UTC | #2

    I'm not sure what you mean. What kind of "message"? Are you trying to interact with the PureCloud UI? If you can explain what you're trying to accomplish, that would be helpful as well.


    vitaly | 2018-07-02 20:09:42 UTC | #3

    Thanks Tim,

    This is related to the https://developer.mypurecloud.com.au/forum/t/embeddable-framework-example-throws-an-error/2812/6 topic where @Junji_Sawada explains communication from a parent page to an embedded client iFrame using contentWindow.postMessage(). I am wondering what is the recommended way of communication in the other direction. For example, to invoke a function on the parent page from the screenPop method in the framework.js to use our CRM API for screen pop.


    Travis_Cawthorn | 2018-07-05 13:41:44 UTC | #4

    Vitaly,

    A very common and acceptable approach would be to use a windows.postMessage to handle this type of communication. One thing to note, with windows.postMessages, is that you will would want to restrict the message to a specific domain otherwise you may run into security implications.


    vitaly | 2018-07-12 22:02:04 UTC | #5

    Travis,

    Yes, according to the topic I mentioned above it seems to be a reasonable approach. The question is how to get a target Window object considering it is a parent window of a different origin i.e. window.parent would not work.

    Amendment: we are integrating with Microsoft Dynamics and some extra investigation revealed that parent.postMessage() is blocked by Azure Crossdomain.js with an error message "Response from Invalid domain: https://apps.mypurecloud.com.au".

    Our current workaround is to send an initialization message to framework.js so it can store a reference to event.source, which can be used for sending messages to a parent window.

    I am wondering if this approach is of any concern?


    system | 2018-08-05 19:16:18 UTC | #6

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 3099