Last Updated: February 25, 2016
·
14.8K
· zigotica

Add custom poster frame to youtube video without the API

The trick is adding the iframe in a comment. Javascript reads comment contents and saves iframe definition to a var. When user clicks on the image, javascript overwrites container innerHTML using the iframe defined in the comments.

https://gist.github.com/4438876

This code is also valid in browsers not supporting window.postMessage (API uses postMessage).

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside