Home Reference Source Test Repository
public class | source

SandboxSender

Message sender for sandbox iframe using postMessage.

Example:

    const iframe = document.getElementById("sandbox");
    const messages = ["FOO", "BAR"];  // or { FOO: "foo", BAR: "bar" }
    const sender = new SandboxSender(iframe, messages);

    sender.sendFoo();
    sender.sendBar({ abc: 1, def: "x" }).then(response => { ... });

Constructor Summary

Public Constructor
public

constructor(iframe: IframeElement, messageTypes: string[] | Object<string, any>, options: Object)

Public Constructors

public constructor(iframe: IframeElement, messageTypes: string[] | Object<string, any>, options: Object) source

Params:

NameTypeAttributeDescription
iframe IframeElement

iframe element to which messages are sent.

messageTypes string[] | Object<string, any>

Known message types.

options Object
  • optional

Options.

options.timeout number
  • optional
  • default: 30000

Request timeout milliseconds.

Test: