Maxforms / Docs

Embed → JavaScript API

JavaScript API

Once the SDK loads, window.Maxforms is a function you call with a command and arguments. All calls are safe to make before the SDK finishes loading — they queue and replay automatically.

1. openPopup

Maxforms('openPopup', {
  formId: 'YOUR_FORM_CODE',
  layout: 'modal',           // 'modal' | 'drawer-right' | 'drawer-bottom'
  width: 560,                // modal only
  overlay: true,
  autoClose: 1500,           // ms after submit, optional
  hideOnSubmit: false,
  hiddenFields: {            // pre-fill declared hidden fields
    ref: 'launch',
    utm_campaign: 'spring'
  },
  onSubmit: function (payload) {
    // payload = { formId, embedId, submissionId, page }
  }
});

2. closePopup

Maxforms('closePopup', 'YOUR_FORM_CODE');
// or
Maxforms('closePopup', { formId: 'YOUR_FORM_CODE' });

3. on / off

Subscribe to lifecycle events:

function handleSubmit(payload) {
  console.log('Form submitted:', payload.formId, payload.submissionId);
}

Maxforms('on', 'maxforms.form.submitted', handleSubmit);

// Later:
Maxforms('off', 'maxforms.form.submitted', handleSubmit);

See Events for the full event vocabulary.

4. init

Reserved for future features (e.g. team-level keys). In v1 it's a no-op and you don't need to call it.

Maxforms('init', { teamKey: 'reserved-for-future-use' });