Javascript 有没有办法在Vimeo视频播放完毕后关闭放大镜?
希望你能帮助我。我有一个放大的iframe弹出窗口,可以播放Vimeo视频。但是,一旦完成,我想自动关闭弹出窗口。这甚至可以通过这个插件实现吗 我的当前(工作代码): 我搜索了web和官方的放大API文档,但没有成功 任何正确方向的帮助或点头表示感谢 非常感谢,, Mikey.添加iframe标记:Javascript 有没有办法在Vimeo视频播放完毕后关闭放大镜?,javascript,jquery,magnific-popup,Javascript,Jquery,Magnific Popup,希望你能帮助我。我有一个放大的iframe弹出窗口,可以播放Vimeo视频。但是,一旦完成,我想自动关闭弹出窗口。这甚至可以通过这个插件实现吗 我的当前(工作代码): 我搜索了web和官方的放大API文档,但没有成功 任何正确方向的帮助或点头表示感谢 非常感谢,, Mikey.添加iframe标记: $vimeo.magnificPopup({ closeBtnInside: false, showCloseBtn: false, disableOn: 0, t
$vimeo.magnificPopup({
closeBtnInside: false,
showCloseBtn: false,
disableOn: 0,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 0,
preloader: true,
fixedContentPos: false,
iframe: {
markup: '<div class="mfp-iframe-scaler">'+
'<div class="mfp-close"></div>'+
'<iframe id="player1" class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
'</div>', // HTML markup of popup, `mfp-close` will be replaced by the close button
patterns: {
youtube: {
index: 'youtube.com/', // String that detects type of video (in this case YouTube). Simply via url.indexOf(index).
id: 'v=', // String that splits URL in a two parts, second part should be %id%
// Or null - full URL will be returned
// Or a function that should return %id%, for example:
// id: function(url) { return 'parsed id'; }
src: '//www.youtube.com/embed/%id%?autoplay=1' // URL that will be set as a source for iframe.
},
callbacks: {
beforeOpen: function() {
cache.$main.addClass('playing');
},
open: function() {
$(this.currItem.el).closest('.project__item').toggleClass('playing');
},
close: function() {
$('.project__item').removeClass('playing');
},
afterClose: function() {
cache.$main.removeClass('playing');
}
}
});
“onFinish”是关闭放大弹出窗口的函数:
var onFinish = function(){
$vimeo.magnificPopup.close();
}
#player1与HTML的哪一部分完全相关?iframe本身?这是您的iframe的id例如:iframe是由放大镜生成的,它没有id。它确实有一个类名,但为.mfp iframeuse标记属性:iframe:{标记:'+'+'+'',//弹出窗口的HTML标记,
mfp close
将替换为close按钮
var iframe = $('#player1')[0];
var player = $f(iframe);
player.addEvent('finish', onFinish);
var onFinish = function(){
$vimeo.magnificPopup.close();
}