Hey guys, I was able to make this work with multiple videos by changing the script to trigger on .class instead of #id.
I am not a javascript guru, so please, let me know if this is not a best practice.
Here’s what to do in three steps:
1. Add this modified version of @cyberdave 's script into the Before Body of page:
<script>
$(document).ready(function() {
$('.closevid').click(function() {
StopEmbedVideo();
});
});
function StopEmbedVideo() {
var $frame = $('iframe.embedvideo');
// saves the current iframe source
var vidsrc = $frame.attr('src');
// sets the source to nothing, stopping the video
$frame.attr('src','');
// sets it back to the correct link so that it reloads immediately on the next window open
$frame.attr('src', vidsrc);
}
</script>
2. Give your iframe a class of ‘embedvideo’.
3. Give your close button div a class of ‘closevid’.
Finally, publish and you are all set.
I hope this helps!