비디오를 닫은 후에도 계속 재생할 수 있습니다. jQuery에서 누락 된 부분이 있습니다. 아무도 도와주세요. 아래 코드는 관련된 코드입니다.임베디드 비디오는 닫은 후에도 계속 재생됩니다.
jQuery를
는$("[data-media]").on("click", function(e) {
e.preventDefault();
var $this = $(this);
var videoUrl = $this.attr("data-media");
var popup = $this.attr("href");
var $popupIframe = $(popup).find("iframe");
$popupIframe.attr("src", videoUrl);
var left = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var left = left/2 - 340;
var top = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
var top = top/2 - 180
document.getElementById("vid").style.top = top + "px";
document.getElementById("vid").style.left = left + "px";
$this.closest(".page").addClass("show-popup");
});
$(".popup").on("click", function(e) {
e.preventDefault();
e.stopPropagation();
$(".page").removeClass("show-popup");
});
$(".popup > iframe").on("click", function(e) {
e.stopPropagation();
});
HTML은
<div class="page"> <!-- class "page" is required for video to work-->
<div class="popup" id="media-popup"> <!-- video embedded -->
<iframe id="vid" src="http://testvideo.com" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</div><!-- popup -->
</div>
그리고 어떻게 닫을까요? – Viney
안녕하세요. 동영상 외부의 아무 곳이나 클릭하여 닫습니다. – Bob