Skip to main content

JavaScript code vs iframe

Open Videos → video → Embed & Share. Under Embed snippet, choose JavaScript or Iframe, then select Copy code.

Copy the embed code

  • JavaScript is recommended. Use it wherever the page accepts custom HTML and external scripts.
  • Iframe is for pages that allow an iframe but block scripts.

Differences​

JavaScriptIframe
The page must allow scriptsYesNo
Where to copy itEmbed & Share and the workspace catalogEmbed & Share only
What the code points toThe player IDThe video's share link on watch.atomicplayer.ai, followed by /embed
window.atomicplayer and DOM events on your pageYesNo. The player sends atomicplayer:event messages to the parent page
A/B test embedYesNo
Who can watchAppliesApplies
Domain lockPlays only on allowed domainsOnly allowed domains can frame it

Things to know about the iframe​

  • The iframe code contains the share link. While the video is Unlisted, that link includes a secret. If you select Reset link, or switch the video to Unlisted, copy the iframe code again. See Share pages and who can watch.
  • An Embed only video plays in the iframe, even though its share page shows a notice.
  • Playback is reported against the page that holds the iframe, not the watch address. If your site sends a stricter referrer policy, analytics may only get its domain.

If a page builder removes <script> but you still want the JavaScript embed, move the runtime line to the platform's site-wide custom-code area and keep the player container where the video should appear.

Frequently asked questions​

Can I choose iframe in Embed & Share?

Yes. Choose Iframe under Embed snippet, then select Copy code.

What if my builder removes scripts?

Use the Iframe code, or the builder's custom-code or header/footer script feature with the JavaScript code. Keep the data-player-id container in the page body.

Why did my iframe stop playing?

Check Who can watch. Private videos don't play in embeds, and a reset Unlisted link breaks iframe code copied before the reset.