# Executing JavaScript in the context of another io.Connect Window

**URL:** <https://community.interop.io/t/executing-javascript-in-the-context-of-another-io-connect-window/625>\
**Category:** io.Connect Desktop\
**Tags:** FAQs, iocd-10, iocd-9, JavaScript\
**Created:** [July 29, 2026, 9:46pm UTC](https://community.interop.io/t/executing-javascript-in-the-context-of-another-io-connect-window/625 "2026-07-29T21:46:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![toni.petrov](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.interop.io/toni.petrov/32/17_2.png) [@toni.petrov](https://community.interop.io/u/toni.petrov)\
**Post date:** [July 29, 2026, 9:46pm UTC](https://community.interop.io/t/executing-javascript-in-the-context-of-another-io-connect-window/625/1 "2026-07-29T21:46:51Z")

</div>

## Question

I want to execute a JavaScript function within the context of another window running in io.Connect Desktop, calling a function exposed by a third-party web application hosted in the platform.

I know this can be done outside io.Connect by creating an Electron window and using the Node APIs to execute JavaScript in the `BrowserWindow`. I’d prefer to do it within io.Connect, to take full advantage of its windowing and interop capabilities. Is there a supported way to do this?

## Answer

Yes. Use the `executeCode()` method, which executes code in the context of an io.Connect Window. It is available on [`IOConnectWindow`](https://docs.interop.io/desktop/reference/javascript/windows/ioconnectwindow/index.html#IOConnectWindow-executeCode) instances and was introduced in io.Connect Desktop 9.5.

Executing JavaScript code within the context of an io.Connect Window is **disabled by default**. To enable it, set the `"allowScriptExecution"` top-level property to `true` in the app definition of the application that will execute the code:

```json
{
    "allowScriptExecution": true
}

```

To execute code, obtain a reference to the target io.Connect Window and call `executeCode()` on it, passing the code as a string. The method resolves with the result returned from the executed code, or rejects if the result of the code is a rejected `Promise`:

```javascript
const ID = "2506_04";
const ioConnectWindow = io.windows.findById(ID);
const myCode = "(() => { return 42; })()";

const result = await ioConnectWindow.executeCode(myCode);
console.log(result);

```

## References

- [`IOConnectWindow.executeCode()` API reference](https://docs.interop.io/desktop/reference/javascript/windows/ioconnectwindow/index.html#IOConnectWindow-executeCode)
- [Window Management — JavaScript](https://docs.interop.io/desktop/capabilities/windows/window-management/javascript/index.html)
