1

I'm trying to implement easyXDM into our current project so that users were able to work with several systems during one workflow with access from a single interface. In other words when a user opens page X the application from another domain should be loaded into an iframe for user to work with (user must authenticate first).

The task itself has a requirement that a certain part of an application should be opened depending on some conditions (lets say that for user from department A we should open form Af in the said application).

So here is the logic I'm trying to code here:

  1. User opens page X (the Consumer)
  2. Iframe with application's login page (the Provider1) is loaded into iframe on Consumer
  3. User logs into the application
  4. JS on the Consumer receives headers from the Provider1
  5. JS on the Consumer loads Provider2 with headers received earlier and tells the Provider2 to navigate to a certain form
  6. JS inside the Provider2 receives a message from the Consumer and navigates to a certain form inside this application.

Here's what I got for now (pretty much a simple example from easyXDM readme):

Provider

    var socket = new easyXDM.Socket({
        onMessage: function(message, origin){
            // do something
        }
    });

Consumer

var socket = new easyXDM.Socket({
    remote: "http://remote/page",
    container: "test",
    onMessage: function(message, origin){
        alert("Received '" + message + "' from '" + origin + "'");
        var socket1 = new easyXDM.Socket({
            remote: "http://remote/page2",
            container: "test",
            headers: providers2_headers,
            onMessage: function(message, origin){
                alert("Received '" + message + "' from '" + origin + "'");            
            },
            onReady: function() {
                this.container.getElementsByTagName("iframe")[0].style.width = "100%";
                socket1.postMessage("Yay, it works!");
            }
        });
    },
    onReady: function() {
    this.container.getElementsByTagName("iframe")[0].style.width = "100%";
        socket.postMessage("Yay, it works!");
    }
});

The question

How to get headers from the Provider1 and use them to load the Provider2?

Liam
  • 27,717
  • 28
  • 128
  • 190
konart
  • 1,714
  • 1
  • 12
  • 19
  • possible duplicate of [How to communicate between iframe and the parent site?](http://stackoverflow.com/questions/9153445/how-to-communicate-between-iframe-and-the-parent-site) – Liam Jul 02 '14 at 09:01
  • Hardly so. I'm able to communicate between iframe and the parent site via easyXDM that utilizes cross-document messaging mentioned there. The problem in my case is more... specific, I think. – konart Jul 02 '14 at 09:05
  • But the answers basically the same, no? `Provider1` communicates with the `Consumer` the `Consumer` loads `Provider2`. – Liam Jul 02 '14 at 09:14
  • Yeah and that's what I wrote, the question - how do I get the needed headers from the Provider1 first. Maybe I should edit the title to make it more relevant. – konart Jul 02 '14 at 10:04

0 Answers0