Introduction

An HtmlComponent is a container for internal or external HTML code.

The HTML component creates a sandboxed environment (an iframe) that doesn't have direct access to the other elements on your page. This means that widgets or libraries that need access to the rest of your page won't work in an HTML component. You can, however, pass data between your page code and the code in an HTML component so you can use it in all sorts of situations to do things you can't normally do directly.

You can embed the following using an HTML component:

  • Sites: Display an external site page in an element on your page.
  • Your own HTML code: Embed your own HTML code, or functionality from an external provider, for example a badge, a newsletter signup form, or a YouTube video.
  • External HTML widget code: Widget code from a 3rd-party provider. Note that widgets that need to collect information about the Wix elements on your page won't work in an HTML component. Widgets that don't need to know any information about the embedding site usually work in an HTML component.

You can send messages from your page code to the code in an HTML component and from the HTML component to your page code using the postMessage() and onMessage() functions. To learn more about what code an HTML component can hold, see here.

Note: To embed a PDF in an HtmlComponent you must upgrade your site to a Premium Plan.

Did this help?