@guillesalazaar's answer was only the 1st half of my correction, so I felt compelled to share my situation if this helps someone in the future. I also have a youtube video embedded, but I set it to play automatically when the frame is loaded using autoplay=1 . To get around the auto-play issue when the page loads, I have a YouTube URL that is stored in a variable that sets the iframe source using a click handler. To solve this problem, I simply deleted the attribute source link:
My url to launch modal window:
<div id="movieClick" class="text-center winner"> <a href="#" data-toggle="modal" data-keyboard="true" data-target="#movie"> </div>
My hidden modal window divs:
<div id="movie" class="modal fade" role="dialog" tabindex='-1'> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">They Live (1988)</h4> </div> <div class="modal-body"> <iframe id="onscreen" width="100%" height="460px" src="" frameborder="0" allowfullscreen></iframe> </div> </div> </div> </div>
My JS:
$("#movieClick").click(function(){ var theLink = "https://www.youtube.com/embed/Wp_K8prLfso?autoplay=1&rel=0"; document.getElementById("onscreen").src = theLink; }); // really annoying to play in the Background...this disables the link $("#movie").on('hidden.bs.modal', function (e) { $("#movie iframe").attr("src", ''); });
Frankenmint Apr 14 '16 at 10:25 2016-04-14 10:25
source share