S
S
sergiofollan2016-04-05 17:04:30
YouTube
sergiofollan, 2016-04-05 17:04:30

How to stop iframe of Youtube video using javascript?

Tell me how to stop a YouTube video on a page created by a tag
Tried the Youtube API, while unsuccessfully doing this:

document.getElementById('video').contentWindow.postMessage('{"event":"command","func":"pauseVideo" ,"args":""}', '*');

And here is the iframe itself:

<iframe id='Youtube' class='center-block' src='https://www.youtube.com/embed/$YoutubeCode?enablejsapi=1' frameborder='0' allowfullscreen></iframe>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cyber_bober, 2016-04-05
@Cyber_bober

var player = document.getElementById('Youtube');
player.stopVideo();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question