Stop YouTube video within iFrame on external Button click

You need to reset the link of the video, i had a similar problem this is how i solved it, i used jQuery in the process.
//First get the  iframe URL
var url = $('#YourIFrameID').attr('src');

//Then assign the src to null, this then stops the video been playing
$('#YourIFrameID').attr('src', '');

// Finally you reasign the URL back to your iframe, so when you hide and load it again you still have the link
$('#YourIFrameID').attr('src', url);

No comments:

Post a Comment