Skip to main content

JavaScript Loader (Deprecated)

warning

The JavaScript loader is a deprecated method of integrating widgets on a website. The loader will continue to work, but you should use the Web Widget SDK instead.

Once you've generated a URL, you can pass that information on to a JavaScript loader provided by MX. This loader allows you to further configure your Connect Widget, including the size as well as all the supported configuration options, inside the config object.

It also allows you to listen for event messages that indicate loading or a successful member creation.

warning

The event messages handled by onEvent below allow partners to take action in their own codebase in response to events triggered within the Connect Widget's UI. They are intended specifically to allow a partner’s code and the widget's UI to work in concert over a single session, not to give canonical information on the state of a member or other information available by request to the appropriate endpoint, e.g., read member connection status.

Example
Language:javascript

_24
<script src="https://atrium.mx.com/connect.js"></script>
_24
/**
_24
* The reference to "atrium" is a holdover from a legacy API.
_24
* Nevertheless, this is still the correct source for the widget loader
_24
* even in the context of the Platform API.
_24
*/
_24
_24
<script>
_24
var mxConnect = new window.MXConnect({
_24
id: "connect-widget",
_24
iframeTitle: "Connect",
_24
/**
_24
* Callback that for handling all events within Connect.
_24
* Only called in ui_message_version 4 or higher.
_24
*
_24
* The events called here are the same events that come through post
_24
* messages.
_24
*/
_24
onEvent: function (type, payload) {
_24
console.log("onEvent", type, payload);
_24
},
_24
targetOrigin: "*",
_24
})
_24
</script>

Parameters available for the JavaScript loader

ParameterData TypeDescriptionRequired?
configObjectThis object allows you to set additional parameters to load the MX Connect Widget in a specific state.No
heightStringDesired height of the iframe. Defaults to 600 pixels.No
idStringThe id of the DOM element you'll load the widget into.Yes
onEventFunctionA general event handler. Only available with ui_message_version: 4 or higher, which is the required version for the MX Platform API.No
widthStringDesired width of the iframe. Defaults to 100% of the parent.No
urlStringA URL for the widget provided as a response to the POST request above.Yes