window.postMessage. The listener script in your snippet handles both messages. Read this page if you write your own listener, for example in a single-page app.
Messages
{ type: 'polyembed:resize', height: number }
Sent when the widget renders and whenever its content height changes, for example when the trade or funding panel opens. Set the iframe’s height to
height pixels. The reference listener clamps it to between 120 and 2000 pixels, falling back to 260.{ type: 'polyembed:hide', height: 0 }
Sent when no relevant market matches, or the widget isn’t authorized to render on this page. Hide the iframe (
display: none, height 0), and any container around it, so the article shows no empty space.*.
Writing a listener
Always check both the message origin and its source window before acting:Listener