Skip to main content

Posts

Showing posts from February, 2025

Stopping Embedded YouTube Videos with JavaScript in 2025

 It's easy to embed a YouTube video on your web page by inserting something like this into the HTML: <div class =" youtube_responsive "> <iframe allow =" accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture " allowfullscreen ="" frameborder =" 0 " src =" https://www.youtube.com/embed/amgybZEP-TI?enablejsapi=1 " title =" YouTube video player "> </iframe> </div> What's more tricky is doing things with it once it's there. For example, you might want it to start playing automatically and if you Google, you'll find lots of (mainly) old stuff about how to do it. Unfortunately, those techniques don't work any more because YouTube "depreciated" them. That's why the title of this post about stopping a video playing says "in 2025" because it may become out of date - although my technique is quite brutal and I'm not sure that YouTu...