How to start using easyXDM to communicate from 3rd party application loaded via an IFrame to 1st party application?

134 views
Skip to first unread message

andiw...@gmail.com

unread,
Apr 11, 2016, 9:30:35 PM4/11/16
to easyxdm
Hello there,

I am a bit confused right now. I followed the examples and successfully posted messages between an iframe and its parent.
What I do not really understand is how to use easyXDM in a real application that is loaded in an IFrame.
Do I need to load the application via easyXDM and set the "container" option in the consumer configuration so that the IFrame where my application is laoded is visible in the parent website?

I have the following scenario:

A Website "Publisher" loads an application in an IFrame via some non blocking techniques like described here http://www.lognormal.com/blog/2012/12/12/the-script-loader-pattern/
I need to call a Url of the Publisher Website via JavaScript to add some items into the cart. As browser security does not allow me to call those urls from within my IFrame and CORS headers are not an option I thought I can do it with easyXDM. I can not upload easyXDM script with the cors folder to the publishers website. But I am able to execute JavaScript on the publisher website via a JavaScript file that is loaded via a script tag.
My solution would be to create a function in the global namespace that makes the post request to the cart url whenever I send an appropiate message via easyXDM.

- Publisher Website with easyXDM consumer waiting for message.
- My application with easyXDM provider sending a message when I want to add a cart item.
- Publisher Website receives message and calls cart url to add cart item


So my questions are the same.


1. How do I create the easyXDM provider? Inside the AngularJS application?

2. Do I need to load my application via easyXDM i.e. {remote: "Url to my application"}

2.1 or can the provider sit in an extra hidden IFrame that is maybe a route of my application where the easyXDM rpc/socket object is created and then passed around in my app?



If someone could point me in the right direction I would appreciate it.


Andi


Reply all
Reply to author
Forward
0 new messages