Passing data to an Inline Frame

Is it possible to pass data from the perspective session into an Inline Frame? Does the page inside the inline frame have access to the custom properties or anything? There’s nothing in the documentation about this and I’m just wondering if it’s possible at all.

1 Like

No, the inline frame is just a “portal” of sorts and has no insight into the fact that it’s within a page/view. If you want to pass parameters, you could conceivably construct a url as the inline frame source which has the expected parameters.

1 Like

As you were typing this response I thought of how I could do it, and that would be dynamically generating a source URL with a binding and then using that to pass parameters/data.

Thanks!

If anyone is curious, the solution I’m doing is this, it seems to be one of the only ways to do this, and might not be the best.

  1. Create a data object in the custom properties for the IFrame.
  2. Store all data you want to send into the IFrame in this object.
  3. Set the src property to a property binding bound to that data property with a Script transform set like this:
import base64
	
base_url = "http://localhost:8080/?data="
data_str = str(value)
return base_url + data_str

This encodes the data property as base64 and throws it into the query string under the data key. This can then be accessed in the page in JavaScript:

var urlParams = new URLSearchParams(window.location.search);
var b64data = urlParams.get('data');
var data = JSON.parse(atob(b64data));

and data is now a JavaScript object that is equal to the data passed in from the Perspective view!

1 Like

Hello,

with this method could you retreive data as well? i mean; im with a localhost page as well and i want to get the final navigated url but the src is binded to the root url