--- title: "Cross-Frame communication with Proxy" slug: "connector-spo-pp-webpanel-tutorials-cross-frame" updated: 2026-09-25T16:29:24Z published: 2026-09-25T16:29:24Z canonical: "docs.discngine.com/connector-spo-pp-webpanel-tutorials-cross-frame" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.discngine.com/llms.txt > Use this file to discover all available pages before exploring further. # Cross-Frame communication with Proxy When creating an instance of [SpotfireDocument](https://connector.discngine.com/spotfire/pipelinepilot/SpotfireDocument.html), you can control pretty much any aspect of the Spotfire instance with it. However, this instance can only be done in the current document and cannot be shared to other iframes if they reside on a different domain. This is what happens for example in the SWAPP. When we load the result page of a protocol, this is done in an iframe. If the iframe is on the same domain, we can easily pass it the instance of the `SpotfireDocument`. It can then manipulate the document easily. But if the frame is on a different domain, this cannot be done. In this case, the only way to communicate between the two frames is through the [Message API](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage). ![Cross-Domain Frame cannot access object](https://connector.discngine.com/images-doc360/spo_pp/client_automation_tutorials/cross-frame/cross-frame-1.png) Cross-domain frame cannot access object. ![Cross-Domain Frame communicating through messages](https://connector.discngine.com/images-doc360/spo_pp/client_automation_tutorials/cross-frame/cross-frame-2.png) Cross-domain frame can communicate using messages. To simplify the implementation of the cross-frame communication, we provide two classes: [SpotfireMessageHandler](https://connector.discngine.com/spotfire/pipelinepilot/SpotfireMessageHandler.html) and [SpotfireDocumentProxy](https://connector.discngine.com/spotfire/pipelinepilot/SpotfireDocumentProxy.html). The `SpotfireMessageHandler` class must be instanciated on the frame containing the `SpotfireDocument` instance. It takes as argument the `SpotfireDocument` instance and optionally the domain of the frame we target. If we do not set the target frame domain, the wildcard "*" will be used. For security reasons, it is strongly recommended to set the domain. In our case, that would be: ``` // On Main frame const spotfireDocument = new SpotfireDocument({ serverUrl: 'https://spotfire.domain.com', documentPath: '/Discngine/Client Automation/empty' }) const spotfireMessageHandler = new SpotfireMessageHandler(spotfireDocument, 'https://b.domain.com') ``` On the other frame, located in b.domain.com, we instantiate the `SpotfireDocumentProxy` class. It takes the window object of the target frame (in our case `window.parent`) and similarly the target frame domain which is optional but strongly recommended. Once done, we can then use it to call any method of the SpotfireDocument instance. Because the message API is asynchronous, all methods of the `SpotfireDocumentProxy` are asynchronous as well, even those which are synchronous on the SpotfireDocument like createWhereClauseForColumnAndValues. ``` const spotfireDocumentProxy = new SpotfireDocumentProxy(window.parent, 'https://a.domain.com'); // Then we can use any method to retrieve data. const test = async () => { const activeDataTable = await spotfireDocumentProxy.getActiveDataTableAsync() console.log(activeDataTable); const properties = await spotfireDocumentProxy.getPropertiesAsync(); console.log(properties) } test() ```