Skip to main content
2 of 5
added 122 characters in body; edited body
dpw4050
  • 419
  • 2
  • 10

When working with YouTube videos in HTML you need to use an <iframe> to display the video. The <object> and <embed> tag combination only works with video that have not been encode through YouTube or other video service, for example: mp4, Adobe Flash, or ogg.

  1. Rewrite the URL from https://www.youtube.com/watch?v=lncOvjE4Fko to https://www.youtube.com/embed/lncOvjE4FkoThis will allow the video to be played natively in the popup.
  2. If you want the video to start automatically when the page loads add ?autoplay=1 to the end of the URL.
  3. Replace the piece of code <object width="425" height="355">...</object> and put in the following:

<iframe id="ytplayer" type="text/html" width="640" height="390" src="**URL_GOES_HERE**" frameborder="0"></iframe>

The width and height can be change to be what ever works best for your size of popup, if you use 100% for both height and width it will auto size to window size.

Now when you open the popup the <iframe> will load the video and you should see the play button or if you added the ?autoplay=1 parameter in the URL it will start playing automatically.

dpw4050
  • 419
  • 2
  • 10